| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
The reverse-proxy templates set `proxy_set_header Host $host`, which normalises the Host header and drops any non-standard port, and they never forward the request scheme. Downstream apps that build absolute URLs from the request (e.g. Drupal, Next.js) therefore emit URLs with the wrong port and scheme when the proxy is published on a non-standard host port such as https://app.local:37103 — the generated links point at https://app.local (port 443) and 404. Use $http_host to preserve the exact Host the client sent (including the port), and forward X-Forwarded-Proto $scheme so the backend knows the public scheme. Both listen ports (80/443) share one server block, so $scheme is correct for either. Applied to all four reverse-proxy variants (proxy, nextjs, storybook, vite); the drupal variant already passes HTTP_HOST/HTTPS via fastcgi_params. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The main difference, $http_host has the value of the Host header sent by the browser, where $host is derived from nginx configuration. (docs). For our use-case, the former is better, since we shouldn't have anything accessing the proxy that does not send a proper Host-header. |
Sorry, something went wrong.
Changes were merged in reload/https-proxy#81 so no need to override them here anymore.
| Back | FazBrowse Home | New Git URL |
Problem
The reverse-proxy templates use proxy_set_header Host $host and don't forward the request scheme.
When the proxy is published on a non-standard host port (e.g. https://app.local:37103), any backend that builds absolute URLs from the request headers — Drupal, Next.js, etc. — generates them as https://app.local/... (i.e. port 443). Those links then 404 because the app is only reachable on :37103.
Root cause: Docker NATs the published port down to the container's :443, so the only place the real public port survives is the client's Host header — which $host discards.
Fix
Applied to all four reverse-proxy variants: proxy, nextjs, storybook, vite. The drupal variant is unaffected — it serves via fastcgi and already passes HTTP_HOST/HTTPS from the connection.
Testing
Verified against the proxy variant in a dev stack published on :37103: a request-derived redirect that previously returned Location: http://app.local/frontpage now correctly returns https://app.local:37103/frontpage, and Drupal-generated login/image URLs carry the right scheme and port. The other three variants take the identical change to the same directive.
🤖 Generated with Claude Code