HTTP to HTTPS redirect is not working

Please fill out the fields below so we can help you better. Note: you must provide your domain name to get help. Domain names for issued certificates are all made public in Certificate Transparency logs (e.g. https://crt.sh/?q=example.com), so withholding your domain name here does not increase secrecy, but only makes it harder for us to provide help.

My domain is:heyjey.com

I ran this command: HTTP to HTTPS is not working.

It produced this output:server {
listen 80;
listen [::]:80;

listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/letsencrypt/live/heyjey.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/heyjey.com/privkey.pem; # managed by Certbot
ssl_trusted_certificate /etc/letsencrypt/live/heyjey.com/chain.pem;

# Improve HTTPS performance with session resumption
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;

# Enable server-side protection against BEAST attacks
ssl_prefer_server_ciphers on;
ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5;

# Disable SSLv3
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

# Diffie-Hellman parameter for DHE ciphersuites
# $ sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 4096
ssl_dhparam /etc/ssl/certs/dhparam.pem;

# Enable HSTS (https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security)
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains";

# Enable OCSP stapling (http://blog.mozilla.org/security/2013/07/29/ocsp-stapling-in-firefox)
ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 5s;

# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html index.php;

server_name heyjey.com;

My web server is (include version): nginx

The operating system my web server runs on is (include version): Ubuntu

My hosting provider, if applicable, is: Digital Ocean

Hi @facildeanotar

there is no redirect defined.

But a mixed definition (port 80 and port 443 in the same server block) is terrible.

First step: Split that in two definitions, one port 80, one port 443.

Then the nginx documentation has a lot of samples how to create a redirect http -> https.

1 Like

thank you so much. it worked for me.

1 Like