Skip to content

[Ubuntu] Setup https on localhost

  1. install required library

    apt install libnss3-tools -y

  2. download, give permission & copy/move to bin folder:

    wget https://github.com/FiloSottile/mkcert/releases/download/v1.1.2/mkcert-v1.1.2-linux-amd64
    chmod +x mkcert-v1.1.2-linux-amd64
    cp mkcert-v1.1.2-linux-amd64 /usr/local/bin/mkcert

  3. Generate local CA

    sudo mkcert -install
    sudo mkcert -CAROOT

  4. Generate Local SSL Certificates, for example my local domain is “yourdomain.net.local”

    sudo mkcert yourdomain.net.local

  5. Then it will generate, like this

    The certificate is at “./yourdomain.net.local.pem” and the key at “./yourdomain.net.local-key.pem”

  6. install on your web server,

    NGINX, on .conf file :

    server{
    listen 80;
    listen 443 ssl;
    …………
    ssl on;
    ssl_certificate /path/to/yourdomain.net.local.pem;
    ssl_certificate_key /path/to/yourdomain.net.local-key.pem;
    ………….
    }

    APACHE, on .conf file:

    …..
    SSLCertificateFile /path/to/yourdomain.net.local.pem
    SSLCertificateKeyFile /path/to/yourdomain.net.local-key.pem

    …..

  7. restart your apache/nginx service

Share

Comments are closed.