Signal9Signal9 — home
online
back to labs

Publish an HTTPS Site: Nginx Server Block + TLS

MediumNetworking25-35 min
The brief

A new site needs to go live over HTTPS, and the box currently serves only the default nginx page. Your per-session assignment is in /root/case/assignment.env (HOST, DOCROOT, CERT, KEY — the certificate and key are already on disk); read it and publish the virtual host.

Two pieces:

1. A TLS server block that listens on 443 with ssl, sets server_name to HOST, points ssl_certificate/ssl_certificate_key at CERT/KEY, and serves DOCROOT as its root.

2. An HTTP→HTTPS redirect: a server block on port 80 for HOST that returns 301 to the https:// URL, so plain-HTTP visitors are upgraded.

Put the config under /etc/nginx/sites-available/ and enable it with a symlink into /etc/nginx/sites-enabled/ (a file in /etc/nginx/conf.d/ also works). Grading reads the configuration nginx would load (enabled sites and conf.d) — it doesn't start nginx — so nginx -t to check your syntax, but the resulting config is what's graded.

What you'll do
  • Write an nginx TLS server block (listen 443 ssl, server_name, ssl_certificate/key, root)
  • Add an HTTP-to-HTTPS 301 redirect for the host
  • Enable the site so nginx would load it
  • Read the per-session assignment and match HOST, DOCROOT, CERT, and KEY

Hands-on lab: you work on a real Linux box in your browser, graded on the machine's actual state.