-
Notifications
You must be signed in to change notification settings - Fork 87
How to launch a secure local web server (HTTPS)
Lloyd Brookes edited this page Dec 7, 2017
·
6 revisions
Some modern techs (HTTP2, ServiceWorker, MediaDevices.getUserMedia()
etc.) must be served from a secure origin (HTTPS). To launch an HTTPS server you must supply one of the following:
- the
--https
flag -
--key
and--cert
files - a
--pfx
file
The quickest method is to use the --https
flag, this will use the private key and certificate chain built into local-web-server. This example will serve your current project as a secure, static web site.
- Install local-web-server to get the
ws
command
$ npm install -g local-web-server
- Navigate into to your project
$ cd example-project
- Launch the secure webserver.
$ ws --https
Serving at https://mbp.local:8000, https://127.0.0.1:8000, https://192.168.0.100:8000
- Navigating to one of the listed URLs will render a directory listing or your
index.html
, if that file exists.
Next, read how to get the "green padlock" using the built-in certificate.