Friday, December 23, 2016

Nginx - too many redirects

Sorry of the messy conf file. I have been trying everything, so it's become a mess. I want to enable SSL and redirect all traffic to https. Currently, with the below conf file, I can navigate to HTTP with no issues. HTTPS just redirects back to HTTP. If I uncomment line 5, then the browser simply says too many redirects. Any help is appreciated.



UPDATE: Based on the comment below, I updated the conf file. Same issue. The minute I add return 301 I get too many redirects error.



    # Redirect all variations to https://www domain
server {
listen 80;
server_name name.com www.name.com;
# return 301 https://www.name.com$request_uri;

}

server {
listen 443 ssl;
server_name name.com;

ssl_certificate /etc/letsencrypt/live/name.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/name.com/privkey.pem;

# Set up preferred protocols and ciphers. TLS1.2 is required for HTTP/2

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5;

# This is a cache for SSL connections
ssl_session_cache shared:SSL:2m;
ssl_session_timeout 60m;


#return 301 https://www.name.com$request_uri;

}

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...