Nginx too many redirects when redirecting http to https

Nginx too many redirects when redirecting http to https



I'm trying to redirect http to https. I use letsencrypt for ssl certificates. My config looks like this


server
listen 80;
server_name example.com www.example.com;
return 301 https://example.com$request_uri;


server
listen 443 ssl;
listen [::]:443 ssl;

ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;

server_name example.com www.example.com;

root /var/www/landing;

location /.well-known/
root /var/www/;




When I'm trying to access example.com, I get a browser error saying that there were too many redirects. The error occurs for both http://example.com and https://example.com, the server block is accessed when I go to http://www.example.com because I get redirected to https://example.com and then I get the error above.



How can I fix this?






check your site content, as it might have many hardcoded http links.

– hcheung
Sep 10 '18 at 0:58






I'm typing the url in the address bar of the browser and it works if I'm not doing the redirect so I think it doesn't have anything to do with the site content

– Petru
Sep 10 '18 at 5:38






without the redirect, your server listen to both port 80 for http requests and port 443 for https, there is no http url being redirect from port 80 to port 403, of course it "works"!

– hcheung
Sep 10 '18 at 8:24




1 Answer
1



After I did wget -S https://wellcode.com I assumed that the problem was on the dns so in Cloudflare I changed SSL to full and the problem was solved


wget -S https://wellcode.com



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế