Enable SSL for local development

Prajwol KC
readytowork-org
Published in
2 min readMay 11, 2022

--

This document will guide you through the running application on HTTPS mode for local development.

Environment: Mac OS / Unix

This uses the npm package which redirects HTTPS to our HTTP running app. Install the following npm package globally.

GitHub — cameronhunter/local-ssl-proxy: Simple SSL HTTP proxy using a self-signed certificate. Intended for local development only.

Simple SSL HTTP proxy using a self-signed certificate. They are intended for local development only.

npm install -g local-ssl-proxy

After installation use

local-ssl-proxy --source 9001 --target 9000

Here target port is our running application port and source for HTTPS enabled port.

Setup hostname for domain

  1. sudo nano /etc/hosts
  2. Add the following to let our domain redirect to our local server.

127.0.0.1 xxxproject.local

Run SSL proxy with a self-signed trusted certificate for xxxproject.local

We can use it to hostname xxxproject.local, and wildcards are also supported.

  1. Install mkcert (choco install mkcert / brew install mkcert)
  2. Run mkcert -install
  3. Run mkcert xxxproject.local
  4. Run

local-ssl-proxy --key xxxproject.local-key.pem --cert xxxproject.local.pem --source 9001 --target 9000

We should run our project under port 9000 (target port is our application port) whereas 9001 (SSL enabled port for the application)

You’re all set! Just go to https://xxxproject.local:9001 and see your project working!

--

--