Redirect HTTPS straight to the other host's HTTPS page on nginx

headers.redirect.https_downgrade_twin · effort: minutes

Why it matters

The HTTPS homepage of this host redirects visitors to the plain http page of its www or non-www twin, although the twin serves the site over https itself and visitors lose the encrypted connection on the way. Point the redirect at the twin's https address instead.

The fix

  1. In the port 443 server for example.com, change the return or rewrite that points at http:// so it points at the https:// address of the other host (www.example.com or example.com), then run sudo nginx -t and reload.
nginx
server {
    listen 443 ssl;
    server_name example.com;
    # ssl_certificate lines as before
    return 301 https://OTHER_HOST$request_uri;
}

The examples use example.com. Replace it with your own domain.

Read the documentation (opens in a new tab)

Scan your domain to see whether this applies to you.