HTTPS Secure Server with SSL for local development


# install on Ubuntus
sudo snap install ngrok

# connect your account

# start tunnel
ngrok http 443

# point ngrok to your local web server
# is default url for http-server
ngrok http -host-header=""

Keep in mind that ngrok is not a web server, it won't work for development. It's just a tunnel that'll make your webserver available over HTTPS


# install
npm i -g http-server

# go to the folder where all global node modules are installed
cd `npm root -g`

# go to http-server
cd http-server/bin

# create an SSL cert
# give for common name
openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem

# add alias so it always starts with SSL
alias http-server='cd $(npm root -g)/http-server/bin/ && ./http-server -S -C cert.pem'

This entire thing is probably flawed since we want to serve within a directory and not want to cd to node root every time.

If i try to use keys (cert.pem and key.pem) from a different directory than the one from where i am running http-server it fails to find the key.

I guess i have to generate new keys inside every folder where i want to run it?

Please note that this site and the posts on it are, and will always be, a work in progress. If i waited for perfection, i’d never get anything done.