Why is there an SSL redirect loop?
Both Nginx and Node.js are redirecting HTTP to HTTPS. Fix by setting app.set('trust proxy', 1) in Express so it trusts the X-Forwarded-Proto header from Nginx and knows the request is already HTTPS.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Nginx Common Configuration Mistakes and How to Fix Them
The Upgrade and Connection headers are missing. Add proxy_http_version 1.1, proxy_set_header Upgrade $http_upgrade, and proxy_set_header Connection 'upgrade' to the location block. These are required for the WebSocket protocol upgrade from HTTP.
Nginx is not passing the real client IP. Add proxy_set_header X-Real-IP $remote_addr and proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for. Also set app.set('trust proxy', 1) in Express so it reads the X-Forwarded-For header.
Nginx is not configured with try_files. Add try_files $uri $uri/ /index.html to the location block. This tells Nginx to fall back to index.html for any path that doesn't match a static file, enabling client-side routing.
Still have questions?
Browse all our FAQs or reach out to our support team
