Fix: Nginx Missing HTTP to HTTPS Redirect

Without an HTTP to HTTPS redirect, visitors who type your domain without https:// see an unencrypted page. The fix is a single Nginx server block.

Add HTTP redirect server block
server {
    listen 80;
    listen [::]:80;
    server_name yourdomain.com www.yourdomain.com;

    # Keep ACME challenge accessible for cert renewal:
    location /.well-known/acme-challenge/ {
        root /var/www/certbot;
    }

    location / {
        return 301 https://$host$request_uri;
    }
}
nginx -t && systemctl reload nginx

# Verify:
curl -sI http://yourdomain.com | grep -E "HTTP|location"
# Should show: HTTP/1.1 301 and location: https://...

Paste your nginx.conf to detect missing SSL redirects automatically.

Open Tool →

Related Glossary Terms