Skip to content

nginx: emit relative redirects so a mapped host port survives directory redirects#56

Merged
roddylindsay merged 1 commit into
EnvelopSound:masterfrom
mormegil6:relative-redirects
Jul 24, 2026
Merged

nginx: emit relative redirects so a mapped host port survives directory redirects#56
roddylindsay merged 1 commit into
EnvelopSound:masterfrom
mormegil6:relative-redirects

Conversation

@mormegil6

@mormegil6 mormegil6 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

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:

$ curl -sI http://host:8081/webtools
HTTP/1.1 301 Moved Permanently
Location: http://host/webtools/      # port 80, wrong service

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 HTTP server level makes nginx emit a relative Location, which the browser resolves against the request URL and keeps the port:

$ curl -sI http://host:8081/webtools
HTTP/1.1 301 Moved Permanently
Location: /webtools/                 # relative, resolves to :8081/webtools/

$ curl -sIL http://host:8081/webtools | tail -1
HTTP/1.1 200 OK

One directive, applied to both nginx.conf and nginx-no-ssl.conf. No behaviour change for deployments served directly on 80/443.

Verified

On a live deployment publishing the transcoder on :8081 behind a Docker + Tailscale bind: before, /webtools 301'd to http://host/webtools/ (dropped port); after, it 301s to a relative /webtools/ and the follow-up request lands on :8081 with 200.

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.
Copilot AI review requested due to automatic review settings July 24, 2026 12:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 server level using absolute_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.

@roddylindsay
roddylindsay merged commit ac1dda7 into EnvelopSound:master Jul 24, 2026
2 of 4 checks passed
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.

3 participants