HTTPS on localhost

March 29, 2025

2 mins read

TLDR:

Use mkcert, and local-ssl-proxy.

sudo apt install libnss3-tools 
curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64" 
chmod +x mkcert-v*-linux-amd64 
sudo cp mkcert-v*-linux-amd64 /usr/local/bin/mkcert
 
mkcert -install 127.0.0.1 localhost
 
sudo npx local-ssl-proxy --source 443 --target 3000 --cert cert.pem --key key.pem

I always had a hard time understanding how to setup HTTPS locally. It seems that there are a lot of configuring to do, and you might risk your set up if it is configured incorrectly. I was hesitant to tinker with my configs, but I had this task that I am required to have it locally setup for me to continue. So, I had no choice 🤧.

I did some digging and I was able to reach this Reddit comment. It was actually as easy as spreading butter on your toast.

🏃Steps

  1. Install mkcert. You can follow their installation guide in Github as well.

    sudo apt install libnss3-tools 
    curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64" 
    chmod +x mkcert-v*-linux-amd64 
    sudo cp mkcert-v*-linux-amd64 /usr/local/bin/mkcert
  2. Install mkcert for any specific local address you have. In my case, 127.0.0.1 and localhost . It would then generate a cert, and a key.

    mkcert -install 127.0.0.1 localhost
  3. Lastly, run local-ssl-proxy. Make sure to reference the cert, and key from #2. Source is the port that will have the https, and target is the port that you want to convert to https.

    sudo npx local-ssl-proxy --source 443 --target 3000 --cert key.pem --key key.pem

📄Note

  • Upon doing mkcert -install it should install the certs as trusted. It will show up in your Chrome > Privacy and Security > Security > Manage Certificates > Authorities.

It is actually not hard, and it is straight forward. Hope you'll be able to setup your own 🥹.

© 2025 Alec Blance

Bacolod, PH