By TGP
Hi!
I’m completely new to Nginx and followed DigitalOcean’s tutorial on how to set it up with LetsEncrypt! I must have done something wrong though because I am getting a ERR_TOO_MANY_REDIRECTS message when navigating to the site.
Not sure if it makes a difference, but the redirect is for a subdomain (strapi.mysite.com). There is no config for the root domain mysite.com yet.
I have the following config in /etc/nginx/sites-available/mysite.com:
server {
# Listen HTTP
server_name strapi.mysite.com;
location / {
proxy_pass http://strapi;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass_request_headers on;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/strapi.mysite.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/strapi.mysite.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = strapi.mysite.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name strapi.mysite.com;
return 404; # managed by Certbot
}
I’m not quite sure what I did wrong here. I do not see an obvious loop, but perhaps it’s my inexperience with Nginx. Any ideas?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
You question doesn’t offer much info and context. But looking at the conf details above, all looks good to me, at least from Nginx side.
Not sure what other settings you might have done elsewhere.
Perhaps this answer can offer a bit more help https://www.digitalocean.com/community/questions/nginx-too-many-redirects
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.