nginx: emit relative redirects so a mapped host port survives directory redirects#56
Merged
Merged
Conversation
nginx builds directory redirects (for example /webtools to /webtools/) as absolute URLs from its internal listen port. When the transcoder container is published on a different host port (docker -p 8081:80, or behind a reverse proxy / VPN bind), that port is dropped: GET http://host:8081/webtools 301s to http://host/webtools/ on port 80, landing on the wrong service. absolute_redirect off makes nginx emit a relative Location (/webtools/), which the browser resolves against the request URL, keeping the port. Set at the HTTP server level so it also covers /dash and any other directory. Applied to both nginx.conf and nginx-no-ssl.conf; no change for same-port (80/443) deployments.
There was a problem hiding this comment.
Pull request overview
Updates the transcoder’s nginx configuration so directory (trailing-slash) redirects don’t drop externally mapped host ports when the container is published behind Docker port mapping or a reverse proxy.
Changes:
- Disable absolute redirects at the
serverlevel usingabsolute_redirect off;in the SSL-enabled config. - Apply the same directive to the non-SSL nginx config for consistent behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| nginx-transcoder/nginx.conf | Disables absolute redirects in the server block so directory redirects remain relative and preserve mapped ports. |
| nginx-transcoder/nginx-no-ssl.conf | Mirrors the same absolute_redirect off; change for non-SSL deployments to keep redirect behavior consistent. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
nginx builds a directory redirect (a request missing its trailing slash) as an absolute URL using its own internal listen port. When Earshot's transcoder container is published on a different host port (
docker run -p 8081:80, or behind a reverse proxy / VPN bind), that external port is dropped:So
/webtools,/dash, or any directory reached without a trailing slash sends the browser to the wrong place unless it happens to be served on port 80.Fix
absolute_redirect off;at the HTTPserverlevel makes nginx emit a relativeLocation, which the browser resolves against the request URL and keeps the port:One directive, applied to both
nginx.confandnginx-no-ssl.conf. No behaviour change for deployments served directly on 80/443.Verified
On a live deployment publishing the transcoder on
:8081behind a Docker + Tailscale bind: before,/webtools301'd tohttp://host/webtools/(dropped port); after, it 301s to a relative/webtools/and the follow-up request lands on:8081with 200.