>_ IzzyLab

Hands-on task

This task is step 12 of the course “New server: setup from scratch”

HTTPS for shop.local

medium~20 min

Until there's a real certificate, the shop's site should at least encrypt its traffic. Issue a self-signed TLS certificate for shop.local (the CN contains shop.local) valid for at least 90 days, and set nginx up to serve HTTPS on port 443 with it.

What you'll practise:
  • openssl req -x509
  • self-signed certificate
  • nginx ssl
  • tls
  • certificate lifetime

Topic breakdown

A TLS certificate binds a site's name to a public key. A self-signed certificate is signed with its own key rather than by a certificate authority: browsers don't trust it, but the channel is fully encrypted — for a staging box before a real certificate is issued, that's enough. openssl req -x509 issues such a certificate and key in one command; the name goes into the CN field, the validity period is in days. In nginx HTTPS is turned on with the ssl parameter of listen and two directives with the paths to the certificate and the private key.

What's checked

  1. HTTPS answers on port 443
  2. the certificate CN contains shop.local
  3. the certificate is valid for at least 90 days

What it looks like