Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support X-Forwarded-Host #75

Merged
merged 1 commit into from
Jul 17, 2016
Merged

Support X-Forwarded-Host #75

merged 1 commit into from
Jul 17, 2016

Conversation

themihai
Copy link
Contributor

fixes #74

@@ -11,6 +11,7 @@ var (
xForwardedFor = http.CanonicalHeaderKey("X-Forwarded-For")
xRealIP = http.CanonicalHeaderKey("X-Real-IP")
xForwardedProto = http.CanonicalHeaderKey("X-Forwarded-Scheme")
xForwardedHost = http.CanonicalHeaderKey("X-Forwarded-Host")
Copy link
Contributor

Choose a reason for hiding this comment

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

We may also want to extend the RFC7239 header Forwarded to parse the host as well: https://tools.ietf.org/html/rfc7239#section-7.5

7.5. Example Usage

A request from a client with IP address 192.0.2.43 passes through a
proxy with IP address 198.51.100.17, then through another proxy with
IP address 203.0.113.60 before reaching an origin server. This
could, for example, be an office client behind a corporate malware
filter talking to a origin server through a reverse proxy.

o The HTTP request between the client and the first proxy has no
"Forwarded" header field.

o The HTTP request between the first and second proxy has a
"Forwarded: for=192.0.2.43" header field.

o The HTTP request between the second proxy and the origin server
has a "Forwarded: for=192.0.2.43,
for=198.51.100.17;by=203.0.113.60;proto=http;host=example.com"
header field.

@elithrar
Copy link
Contributor

I don't know how I missed this! Thanks @themihai

@elithrar elithrar self-assigned this Jul 17, 2016
@elithrar elithrar merged commit af3022d into gorilla:master Jul 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ProxyHeaders: Support X-Forwarded-Host
2 participants