Any idea why this Nginx config is causing infinite redirects?
listen 80;
server_name site.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name site.example.com;
ssl_protocols TLSv1.1 TLSv1.2;
ssl_certificate /etc/letsencrypt/live/site.example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/site.example.com/privkey.pem; # managed by Certbot
access_log /var/log/nginx/site.example.com.log;
location / {
proxy_redirect off;
proxy_set_header Host $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_pass http://127.0.0.1:8888;
}
location ~ /.well-known/acme-challenge {
root /var/www/site.example.com/;
allow all;
}
}
This is a Digital Ocean droplet, and the purpose is to run Resilio Sync, which sits on 127.0.0.1:8888. When I try to access the site, it just gets redirected to https://site.example.com/ over and over again. As far as I can tell, the return 301 in the first server block is the only thing here that would do a redirect, but I still get this problem even if I comment that line out.
I've pored through the multiple SO questions over the same topic, and none of the solutions seem to apply here. I'm not using CloudFlare. What am I doing wrong here? Everything worked earlier today, except the certificate had expired. The syncing still works fine, it's just the Nginx setup to access the web GUI that doesn't work.