I recently setup letsencrypt with my site, and the SSL works perfectly. However, when I set Nginx to redirect HTTPS to HTTPS, I get a redirect loop where when you visit the website and refresh the URL changes back and forth from example.com to .
This is my configuration:
server { listen 80; server_name example.com return 301 } server { listen 443 ssl; server_name example.com; root /var/www; index index.html; # ssl_certificate, etc... location / { try_files $uri $uri/ /index.html =404; } } What am I doing incorrectly here that causes the redirect loop?
21 Answer
Try to add ssl on; under the line listen 443 ssl; and disable disable SSLv3
server { listen 80; server_name example.com listen 443 ssl; ssl on; server_name example.com; ssl_certificate ssl_certificate_key ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; location / { rewrite ^(.*) permanent; } ... Or you can also use return its way faster than rewrite in niginx location blocks:
location / { return ^(.*) permanent; } Once SSL Done You can test your ssl certificate at
To create chain certificate:
cat bundle.crt > ssl_certificate ssl_certificate_key 2