Back to lessons

Hosting Operations

Check HTTP to HTTPS Redirect

You need to confirm that plain HTTP redirects to HTTPS.

Command

curl -I http://example.com

What changed

Nothing changes. The command requests headers from HTTP.

Danger

safe

When to use it

Use this after SSL setup, DNS changes, or Nginx redirect edits.

When not to use it

Do not follow redirects if you only need the first response; keep `-I` simple.

Undo or recovery

No state is changed.

Expected output

A 301 or 308 redirect with a HTTPS Location header.

demo script

Disposable terminal steps

  1. curl -I http://example.com
  2. curl -I https://example.com
  3. grep -R "server_name" /etc/nginx/sites-enabled/

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ curl -I http://example.com
HTTP/1.1 301 Moved Permanently
Location: https://example.com/

::exit-code::0
$ curl -I https://example.com
HTTP/2 200
server: fake-nginx
x-content-type-options: nosniff

::exit-code::0
$ grep -R "server_name" /etc/nginx/sites-enabled/
/etc/nginx/sites-enabled/example.com:    server_name example.com www.example.com;
::exit-code::0

YouTube Short

Check the HTTP redirect.

A valid cert is not the whole setup. Check the plain HTTP path too.

LinkedIn hook

HTTPS worked. The plain HTTP redirect still mattered.

Question: Do you test HTTP redirects after setting up SSL?

experiments

A/B tests to run

Metric: search_click_rate

A: Check HTTP to HTTPS redirect.

B: HTTPS worked. HTTP still mattered.