vendredi 19 février 2021

Auto redirect http to https using nginx

I guys need help with a thing, I recently set up a node.js webserver using Nginx it works just fine. One day when I was browsing, I saw my business on google and I clicked the "Website" and saw that my website had a http://example.com format, but when I search for http://example.com I automatically get redirected to HTTPS, I think that's because of Cloudflare. Anyway, so I tried reading about it and found that if I add a line to my Nginx default it will redirect HTTP to HTTPS, here's that line

return 301 https://$host$request_uri;

This worked fine, but this caused an issue, my browser said, too many redirects and doesn't open my page... Any solutions?

nginx default screenshot

Thanks for reading!




Aucun commentaire:

Enregistrer un commentaire