Add absolute_redirect off; to prevent broken redirects in containerized environments #567
Closed
beliven-valentino-cossar
started this conversation in
Ideas & Feature Requests
Replies: 2 comments
-
|
Great proposal! Thanks for bringing this to my attention. I just added this here: 077fd62 This will be available in v4.0, but you can start testing it today 🥳 |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Hi @jaydrogers, super! Thank you 🙏 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I would like to propose adding the directive
absolute_redirect off;to bothhttp.conf.templateandhttps.conf.template.Reason and usefulness
When running Nginx inside containerized environments, it is common to have the service listen on a non-standard internal port (e.g., 8080, 8443) which is then mapped to the standard port (80 or 443) on the host. Without
absolute_redirect off;, Nginx may generate absolute redirects that include the internal container port (like:8080or:8443) in theLocationheader. This can break client-side navigation and create confusion, since users actually connect through the standard external ports.By explicitly adding
absolute_redirect off;, Nginx will use relative redirects instead. This ensures that URLs generated in redirects will not leak internal port numbers to external users, providing a more seamless experience across various deployment environments, especially with containerized setups and reverse proxy scenarios.Example
Without
absolute_redirect off;, accessinghttps://mydomain.com/pathmay redirect tohttps://mydomain.com:8443/path/if Nginx listens on8443inside the container. Withabsolute_redirect off;, the redirect will use a relative URL and will not expose the internal port to the client.This is the
https.conf.templatefile as example.If you prefer, I could submit a PR.
Thank you for considering this improvement!
Beta Was this translation helpful? Give feedback.
All reactions