Skip to content

Latest commit

 

History

History
37 lines (26 loc) · 2.04 KB

README.md

File metadata and controls

37 lines (26 loc) · 2.04 KB

This repository belongs with the article "Automatic HTTPS for all your development servers" over at nvnh.io.

It demonstrates how you can use HTTPS in development with any server, without changing the code.
We can do this by running a reverse proxy that will handle HTTPS for us. After trying Traefik and NGINX, Traefik was easier to configure.

The test-app is a test application that demonstrates the use of HTTPS, websockets (WSS) and server-sent events.

Getting started

Prerequisites:

Use mkcert "*.localhost.test" to create 2 files _wildcard.localhost.test.pem and _wildcard.localhost.test-key.pem in the traefik folder of this repository.

Configure your hosts file so that the domains you want to use resolve to localhost.
You can do this by adding these lines to your hosts file (/etc/hosts on unix based systems and C:\Windows\System32\drivers\etc\hosts on Windows):

127.0.0.1   8080.localhost.test
127.0.0.1   8081.localhost.test
...
127.0.0.1   8099.localhost.test

(If you've installed Docker without Docker Desktop, open traefik/docker-compose.yml and uncomment the extra_hosts section)

Go to the traefik folder
Run docker-compose up

You can now access any development server running on ports between 8080 and 8099 over HTTPS by replacing http://localhost:<port> with https://<port>.localhost.test.
For example, you can open https://8099.localhost.test in your favorite browser to see Traefik's dashboard.

To run the test application, go to the test-app folder
Run npm install and npm start

Open https://8080.localhost.test in your favorite browser to see an API call, a websocket over WSS and Server-sent events in action.