A self-signed certificate lets a nonproduction HTTPS site use SSL without obtaining a certificate from a domain provider or Let’s Encrypt. Nginx can terminate SSL centrally instead of requiring certificates in every application container. section 20.2
Create and use one for a local image-gallery site:
- Generate the certificate and key with an OpenSSL-based container, mounting the output into a local certificates directory. section 20.2
- Mount the certificates into Nginx and enable a site configuration that listens on port 443. section 20.2
- Redirect port 80 requests to HTTPS with an HTTP 301 response, then reload Nginx. section 20.2
Local HTTPS warning
Opening image-gallery.local over HTTPS produces a browser warning because the certificate is not trusted. For a development site, proceed through the browser’s advanced option; use trusted certificates in production. 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
Run the certificate generator, install the SSL-enabled Nginx configuration, reload Nginx, and test the local site. section 20.2



