Skip to content

fix(nginx): relative Location on every redirect behind a TLS proxy - #4786

Merged
PierreBrisorgueil merged 1 commit into
masterfrom
fix/4784-nginx-relative-redirect
Oct 27, 2026
Merged

PierreBrisorgueil merged 1 commit into
masterfrom
fix/4784-nginx-relative-redirect

Conversation

@PierreBrisorgueil

@PierreBrisorgueil PierreBrisorgueil commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

What — a directory URL typed without its trailing slash (/about) now redirects with a relative Location: /about/, so behind a TLS-terminating proxy the browser stays on https instead of being sent to http://host/about/.

How — absolute_redirect off; at server level in nginx.example.conf. Inherited by every location, it also covers any return 30x a consumer adds.

Checked — nginx -t ok; served locally: /about → 301 Location: /about/, /about?a=1 → /about/?a=1, /about/ → 200, unknown path → SPA fallback 200.

Closes #4784

https://claude.ai/code/session_012XGDJoHpND6B3qk6SCWKmU

Summary by CodeRabbit

  • Bug Fixes
    • Nginx-generated redirects now use relative URLs instead of absolute URLs.

The image's nginx listens on plain HTTP, so when TLS ends at an upstream
proxy a directory redirect (/about -> /about/) carried an absolute
Location: http://host/about/. absolute_redirect off at server level makes
every redirect relative, so the browser keeps the public scheme and host.

Closes #4784

Claude-Session: https://claude.ai/code/session_012XGDJoHpND6B3qk6SCWKmU
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between c7f4f5b and 04f3cbb.

Files selected for processing: 1
  • nginx.example.conf

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The nginx example configuration sets absolute_redirect off, so nginx-generated redirects use relative locations.

Changes

nginx Redirects

Layer / File(s) Summary
Redirect configuration
nginx.example.conf
Adds a comment about the proxy and TLS context and disables absolute redirects.

Priority: Normal

Estimated code review effort: 1 (Trivial) | ~4 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to 04f3c

The server-level redirect configuration matches the stated TLS-proxy objective.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description explains what changed, why it changed, how it was implemented, the related issue, and the reported validation results. It does not follow the repository template and omits the required… Rewrite the description using the repository template. Add the impacted modules, cross-module impact, risk level, validation checklist, guardrails checklist, and reviewer notes. Retain the existing change rationale, test results, and issue …
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the nginx redirect change and the TLS proxy scenario.
Linked Issues check Passed Issue #4784 requires absolute_redirect off; at server level for nginx.example.conf. The pull request adds this directive to the server block. The existing try_files $uri $uri/ /index.html rema…
Out of Scope Changes check Passed The diff changes only nginx.example.conf. It adds the server-level redirect directive and comments that explain the TLS-proxy case and inherited redirect coverage. These changes support issue #4784 …
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within survi…
Full details: Linked Issues check

Explanation

Issue #4784 requires absolute_redirect off; at server level for nginx.example.conf. The pull request adds this directive to the server block. The existing try_files $uri $uri/ /index.html remains in scope, and the reported checks show relative slash redirects and preserved query strings. The directive also preserves the requested direct-serving behavior while preventing scheme-specific absolute locations behind a TLS proxy.

Full details: Out of Scope Changes check

Explanation

The diff changes only nginx.example.conf. It adds the server-level redirect directive and comments that explain the TLS-proxy case and inherited redirect coverage. These changes support issue #4784 and introduce no demonstrated unrelated behavior.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.)

Full details: Description check

Explanation

The description explains what changed, why it changed, how it was implemented, the related issue, and the reported validation results. It does not follow the repository template and omits the required Scope, Guardrails check, and Notes sections.

Resolution

Rewrite the description using the repository template. Add the impacted modules, cross-module impact, risk level, validation checklist, guardrails checklist, and reviewer notes. Retain the existing change rationale, test results, and issue reference.

Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@codecov

codecov Bot commented Oct 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.62%. Comparing base (8e661d9) to head (04f3cbb).
⚠️ Report is 7 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4786   +/-   ##
=======================================
  Coverage   99.62%   99.62%           
=======================================
  Files          43       43           
  Lines        1585     1585           
  Branches      490      490           
=======================================
  Hits         1579     1579           
  Misses          6        6           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@PierreBrisorgueil
PierreBrisorgueil merged commit aa99044 into master Oct 27, 2026
7 checks passed
@PierreBrisorgueil
PierreBrisorgueil deleted the fix/4784-nginx-relative-redirect branch October 27, 2026 07:11
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.

🐛 nginx directory redirects send an absolute http:// Location behind a TLS-terminating proxy

1 participant