liveBook · Manning

Certificate

As explained in Learn Docker in a Month of Lunches, Second Edition

A digital certificate binds a domain identity to a cryptographic public key for authenticating a network endpoint.

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

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Explains generation, mounting, configuration, and redirection, but defers detailed protocol and cipher choices.
Examples
Uses image-gallery.local, Docker certificate generation, Nginx configuration, HTTP redirection, and a browser trust warning.
What it assumes
Assumes familiarity with containers and Nginx configuration while introducing certificate generation through a runnable exercise.
What you can do after
Operate a local HTTPS endpoint by generating a self-signed certificate and configuring Nginx to serve it.
How it connects
Connects certificates with HTTPS, SSL termination, Nginx, reverse proxies, containers, and self-signed certificates.

Also explained in

Compare how 15 books explain certificate →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.