mirror of
https://github.com/yusing/godoxy.git
synced 2026-01-14 14:23:33 +01:00
Feature Request : Enable X-Forwarded Headers by Default with an Option to Disable per Application #14
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @arevindh on GitHub (Sep 30, 2024).
Currently,
go-proxyonly addsX-Forwarded-*headers (e.g.,X-Forwarded-For,X-Forwarded-Proto,X-Forwarded-Host) when explicitly enabled via Docker labels. These headers are crucial for many applications running behind a reverse proxy to correctly identify the original client IP, protocol, and host, especially when used in combination with Docker.Request:
Enable the inclusion of
X-Forwarded-*headers by default.Reasoning:
The
X-Forwarded-*headers are essential in reverse proxy setups for several reasons:Client IP Identification:
Applications often use the
X-Forwarded-Forheader to obtain the real client's IP address, rather than the internal IP address of the reverse proxy. This is particularly important for features such as:Correct URL and Protocol Handling:
Many web applications rely on the
X-Forwarded-ProtoandX-Forwarded-Hostheaders to determine the original protocol (httpvs.https) and host requested by the client, allowing them to:Popular Proxies:
It is worth noting that other widely used reverse proxies, such as Traefik, Caddy, and NGINX Proxy Manager, enable
X-Forwarded-*headers by default.Traefik: Automatically adds these headers when proxying HTTP requests.
Traefik documentation on forwarded headers
Caddy: The reverse proxy feature adds
X-Forwarded-*headers by default.Caddy documentation on reverse proxy defaults
This is a widely adopted practice in the proxy world as it provides transparency about the client's real information to the application being proxied.
Example Usage:
For instance, web frameworks such as Flask, Express, or Django often utilize middleware or configuration to parse these headers to find the real user's IP behind a proxy.
X-Forwarded-Forwith a configuration setting calledProxyFix.X-Forwarded-Forheader to obtain the client IP behind proxies when configured.X-Forwarded-Forto obtain the correct IP if the app is behind a proxy.Proposal:
go-proxyto automatically includeX-Forwarded-*headers unless explicitly disabled.Please consider this enhancement for a future release as it would provide a more seamless experience for users running applications behind a reverse proxy.
Thank you!
@yusing commented on GitHub (Sep 30, 2024):
ebedbc931f