Skip to content

fix: disable port_in_redirect and absolute_redirect in nginx configs#8826

Open
Vansh5632 wants to merge 1 commit intomakeplane:previewfrom
Vansh5632:fix/nginx-port-in-redirect
Open

fix: disable port_in_redirect and absolute_redirect in nginx configs#8826
Vansh5632 wants to merge 1 commit intomakeplane:previewfrom
Vansh5632:fix/nginx-port-in-redirect

Conversation

@Vansh5632
Copy link
Copy Markdown

@Vansh5632 Vansh5632 commented Mar 30, 2026

Problem

When nginx performs a redirect (e.g., a trailing-slash redirect from /settings to /settings/), it by default generates an absolute Location URL 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:

< HTTP/1.1 301 Moved Permanently
< Location: http://plane.example.com:3000/settings/

Instead of the expected:

< HTTP/1.1 301 Moved Permanently
< Location: /settings/

This breaks navigation in all three frontend apps (web, admin, space) whenever nginx issues a redirect.

Root Cause

nginx's port_in_redirect directive (default: on) appends the server's listen port to the Location header. nginx's absolute_redirect directive (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.

From the nginx docs:
port_in_redirect — Enables or disables specifying the port in absolute redirects issued by nginx.
absolute_redirect — If disabled, redirects issued by nginx will be relative.

Fix

Added the following two directives to the server {} block of all three frontend nginx configs:

absolute_redirect off;
port_in_redirect  off;

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.conf
  • apps/admin/nginx/nginx.conf
  • apps/space/nginx/nginx.conf

Testing

Trigger a trailing-slash redirect against the container directly:

# Without fix
curl -sv http://localhost:3000/god-mode 2>&1 | grep -i location
# Location: http://localhost:3000/god-mode/   ❌ internal port leaks

# With fix
curl -sv http://localhost:3000/god-mode 2>&1 | grep -i location
# Location: /god-mode/                        ✅ relative, proxy-safe

Fixes: #8814

Summary by CodeRabbit

Chores

  • Updated server redirect configuration across admin, space, and web applications to adjust how URLs are handled during server redirects.

…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.
Copilot AI review requested due to automatic review settings March 30, 2026 16:34
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 30, 2026

📝 Walkthrough

Walkthrough

Three Nginx configuration files across different applications (admin, space, web) have been updated to disable absolute URL redirects and port-inclusive redirects by adding absolute_redirect off and port_in_redirect off directives to their respective server blocks listening on port 3000.

Changes

Cohort / File(s) Summary
Nginx Configuration Updates
apps/admin/nginx/nginx.conf, apps/space/nginx/nginx.conf, apps/web/nginx/nginx.conf
Added absolute_redirect off and port_in_redirect off directives to disable absolute URL generation and port numbers in redirect responses.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A hop, a skip, a config change so fine,
Three servers dancing in redirect line,
No more absolute URLs to roam,
Just relative paths to guide you home! 🌿

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: disabling port_in_redirect and absolute_redirect directives in nginx configurations across the three frontend apps.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description comprehensively covers the problem, root cause, fix, files changed, and testing methodology with clear examples.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_redirect in nginx server {} blocks for web, admin, and space.
  • Disable port_in_redirect in nginx server {} blocks for web, admin, and space.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: Admin service redirect broken on fresh install to microk8s

2 participants