Question
How to fix a nginx redirection loop?
Hello,
I’m actually trying to install peertube on my server, but the thing is that there is a redirection loop in my nginx config, and i can’t find it… Can someone help me? Here is my nginx config (of course examples has been replaced with the name of my website
server {
server_name peertube.example.com;
location / {
proxy_buffering off;
proxy_pass http://localhost/;
proxy_redirect off;
client_max_body_size 40G;
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;
}
# Websocket tracker
location /tracker/socket {
# Peers send a message to the tracker every 15 minutes
# Don't close the websocket before this time
proxy_read_timeout 1200s;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://localhost;
}
location /socket.io {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://localhost;
# enable WebSockets
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/peertube.example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/peertube.example.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 = peertube.example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name peertube.example.com;
listen 80;
return 404; # managed by Certbot
}
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×