webzod
account

Stop redirecting HTTPS to HTTP on nginx

headers.redirect.https_downgrade · effort: about an hour

Why it matters

The HTTPS homepage sends visitors back to plain http, so the encrypted connection is thrown away and their traffic is exposed again. It usually means the application believes its address starts with http:// or a redirect rule points the wrong way.

The fix

  1. Search the configuration for redirects to http (grep -rn 'http://' /etc/nginx) and change any return or rewrite in the port 443 server to https://.
  2. If nginx proxies to an application, pass the original scheme so the application builds https URLs, then run sudo nginx -t and reload.
nginx
location / {
    proxy_pass http://127.0.0.1:3000;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
}

Read the documentation (opens in a new tab)

Scan your domain to see whether this applies to you.