fix: disable port_in_redirect and absolute_redirect in nginx configs#8826
fix: disable port_in_redirect and absolute_redirect in nginx configs#8826Vansh5632 wants to merge 1 commit intomakeplane:previewfrom
Conversation
…configs When deployed behind a reverse proxy (e.g., Kubernetes Ingress-nginx), the backend nginx containers generate 301 redirects with the internal listen port :3000 in the Location header (e.g., http://host:3000/god-mode/). This causes ERR_CONNECTION_REFUSED since port 3000 is not externally exposed. Root cause: nginx defaults port_in_redirect to 'on' and absolute_redirect to 'on', so any auto-generated redirect (trailing-slash, index) includes the listen port from the 'listen 3000' directive. Fix: Add 'absolute_redirect off' (emit relative Location headers) and 'port_in_redirect off' (defense-in-depth) to the server block in all three frontend nginx configs (admin, web, space). This is a no-op for Docker Compose deployments where the Caddy proxy already handles trailing-slash redirects before they reach the backend.
📝 WalkthroughWalkthroughThree Nginx configuration files across different applications (admin, space, web) have been updated to disable absolute URL redirects and port-inclusive redirects by adding Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR updates the frontend nginx configurations so redirects generated by nginx (e.g., trailing-slash redirects) are relative and do not leak the container’s internal listen port when deployed behind a reverse proxy.
Changes:
- Disable
absolute_redirectin nginxserver {}blocks forweb,admin, andspace. - Disable
port_in_redirectin nginxserver {}blocks forweb,admin, andspace.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| apps/web/nginx/nginx.conf | Disables absolute/port-including redirects to prevent leaking internal port in Location header. |
| apps/admin/nginx/nginx.conf | Same redirect behavior adjustment for the admin frontend container. |
| apps/space/nginx/nginx.conf | Same redirect behavior adjustment for the space frontend container. |
Problem
When nginx performs a redirect (e.g., a trailing-slash redirect from
/settingsto/settings/), it by default generates an absoluteLocationURL that includes the host and the port it is listening on internally (3000).When Plane is deployed behind a reverse proxy (e.g., Caddy, nginx, Traefik) on the standard ports 80/443, this behaviour leaks the internal container port to end users:
Instead of the expected:
This breaks navigation in all three frontend apps (
web,admin,space) whenever nginx issues a redirect.Root Cause
nginx's
port_in_redirectdirective (default:on) appends the server's listen port to theLocationheader. nginx'sabsolute_redirectdirective (default:on) generates a fully-qualified absolute URL rather than a relative path.Both defaults are appropriate for standalone nginx, but are incorrect when nginx sits behind a reverse proxy.
Fix
Added the following two directives to the
server {}block of all three frontend nginx configs:This ensures that any redirect nginx generates is a relative URL, completely unaffected by the internal listen port. The reverse proxy's own port and host are preserved end-to-end.
Files Changed
apps/web/nginx/nginx.confapps/admin/nginx/nginx.confapps/space/nginx/nginx.confTesting
Trigger a trailing-slash redirect against the container directly:
Fixes: #8814
Summary by CodeRabbit
Chores