Local SSL enables you to redirect an no-secure - even local (localhost) - domain to an secure HTTPS and HTTP/2 virtual domain.
It's pretty good for test your PWA local applications :)
See the version file on the project's root folder.
See the LICENSE file on the project's root folder.
- Fabio Marciano fabioamarciano@gmail.com
- OpenSSL
- Docker
In order to use the local SSL, you will need to:
- generate a local, but valid, certificate;
- build a docker image with some parameters;
- edit your
hostsfile to add the local domain entry; - Add the certificate file on your web browser
The first step is to generate a local certificate for the domain you wish.
This step should be executed one time per domain but must be before to run the docker container.
The setup script utility are able to generate the certificate set you will need.
Use the following command replacing the my-local-domain with your desired domain name.
Let's consider you choose the secure.local domain name. So you will run the following command on terminal:
$ ./setup secure.localThe command above creates the secure.local folder inside the ssl folder.
Note there are 3 files inside it: ca.pem, server.crt and server.key.
These files will be used in the future, so don't move or remove then.
In order to build the Docker's image is necessary to provide some required arguments on the command line:
- domain: the https/secure domain without the protocol. Eg.:
secure.local. - port: port used by Nginx's server (this is for the secure domain). Eg.:
80. - target: the fully target address with the protocol, domain and port - if applicable - Eg.:
http://localhost:3000. - imageName: the docker's image name. Eg.:
local-ssl.
Considering:
domain: secure.localport: 80target: http://localhost:3000imageName: local-ssl
Execute:
$ sudo docker build --build-arg DOMAIN=secure.local --build-arg PORT=80 --build-arg TARGET=http://localhost:3000 -t local-ssl .You should to update your hosts file using your favourite text application to add the following entry:
127.0.0.1 secure.localOr, you may to run the following command to the same effect:
$ echo "127.0.0.1 secure.local" | sudo tee -a /etc/hosts > /dev/nullConsidering you are using
secure.localas your local domain name.
The next step is to add your previous generated certificate file on your web browser.
Let's use the google chrome as example:
- open google chrome
- type on address bar: chrome://settings/certificates
- Click on Authorities and Import
- Go to the your certificate folder at
ssl/secure.localand choose the ca.pem file, then Open - On Certification Authority tab, select/check all options and then Ok
About the local certificates
Each virtual local domain has your own certificate (step #1).
So, if you want to create another certificate, to another virtual domain or from another unsecure domain, it's necessary to repeat all previous described steps using new parameters.
After sucessfully setting up your local domain, it's time to use it.
You don't need to repeat the previous steps each time you use the container unless you need a new local domain name.
Now you are able to run the docker container using the following command:
$ sudo docker run --rm --network=host -it local-sslConsidering you used
local-sslfor theimageNameargument.
Access using the following address on your web browser:
https://secure.local/Use the /health path to check if the service is enabled.
Example:
https://secure.local/health