An SSL certificate enables a reverse proxy to serve an application over HTTPS. Centralizing certificates in Nginx avoids configuring them separately in every application container. section 20.2
A local HTTPS setup follows these steps:
- Generate a self-signed certificate and key with OpenSSL in a container, mounting the output into the local certificates directory. section 20.2
- Mount the certificates into Nginx, install an HTTPS site configuration, and reload Nginx. section 20.2
- Redirect HTTP requests to HTTPS and serve the site on port 443 with the certificate and private key. section 20.2
# generate a self-signed certificate - Linux containers: docker container run -v "$(pwd)/nginx/certs:/certs" ` -e HOST_NAME=image-gallery.local diamol/cert-generator:2e # OR Windows Server containers: docker container run -v "$(pwd)/nginx/certs:C:\certs" ` -e HOST_NAME=image-gallery.Local diamol/cert-generator:2e # remove the existing image-gallery configuration: rm ./nginx/sites-enabled/image-gallery.local # copy in the new site configuration with SSL: cp ./nginx/sites-available/image-gallery-3.local ` ./nginx/sites-enabled/image-gallery.local # and restart nginx: docker exec nginx-nginx-1 nginx -s reload # browse to http:/./image-gallery.local
Use the commands to generate a local certificate for image-gallery.local, install the SSL configuration, reload Nginx, and test the site. section 20.2














