Linux Labs

Web stack / Stage 5 of 9

HTTPS in nginx: chain and redirect

Not running Starting usually ~20 s
Leave the lesson

Step 6 of 7 · lab · 25 minmedium

The shop after a certificate renewal

Since the shop's certificate was renewed, some clients reject it, and links from an old newsletter land on the home page. Fix the shop's HTTPS and the redirect to it.

Situation

The company's online shop store.lab.test runs over HTTPS on this machine's nginx. This month the training certificate authority (CA) renewed the shop's certificate, and the new file replaced the old one. Since then two people have written in.

A developer: "The shop opens in my browser, but curl and our payment service get a certificate error". A marketer: "Links from an old newsletter, like http://store.lab.test/catalog?page=2, open the home page instead of the catalog".

Every company machine trusts the training CA's root certificate, this one included. The certificates the CA signs sites with are published in /srv/lab-ca. The shop's files are in /etc/ssl/store.

Task

  1. curl without -k opens https://store.lab.test/ and gets the shop page.
  2. The shop certificate passes verification on a client that knows only the training CA's root certificate (/srv/lab-ca/root.crt), with no changes on the client side.
  3. http://store.lab.test/ answers with code 301 and redirects to https://store.lab.test/.
  4. The redirect to HTTPS keeps the path and parameters: http://store.lab.test/catalog?page=2 redirects to https://store.lab.test/catalog?page=2.

The machine has no internet access; everything you need is already installed.

Lab · on your own

No commands are given in this lab: type them in the terminal yourself. Goals are checked on the machine after every command.

Goals

0 of 4
  • curl without -k opens https://store.lab.test/ and gets the shop page — not done yet
  • The shop certificate passes verification on a client that knows only the training CA's root certificate — not done yet
  • http://store.lab.test/ answers with code 301 and redirects to https://store.lab.test/ — not done yet
  • http://store.lab.test/catalog?page=2 redirects to https://store.lab.test/catalog?page=2 — not done yet
Ctrl+Enter
Starts the machine node1 · Ubuntu 24.04

The machine is starting

Hints

0 of 3

Lab goals

0 of 4
  • curl without -k opens https://store.lab.test/ and gets the shop page — not done yet
  • The shop certificate passes verification on a client that knows only the training CA's root certificate — not done yet
  • http://store.lab.test/ answers with code 301 and redirects to https://store.lab.test/ — not done yet
  • http://store.lab.test/catalog?page=2 redirects to https://store.lab.test/catalog?page=2 — not done yet
node1 Ubuntu 24.04

Lab goals

0 of 4
  • curl without -k opens https://store.lab.test/ and gets the shop page — not done yet
  • The shop certificate passes verification on a client that knows only the training CA's root certificate — not done yet
  • http://store.lab.test/ answers with code 301 and redirects to https://store.lab.test/ — not done yet
  • http://store.lab.test/catalog?page=2 redirects to https://store.lab.test/catalog?page=2 — not done yet
Loading…