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

Setting Host header in outgoing request, closes #3792 #3796

Merged
merged 1 commit into from
Mar 16, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/github.com/getlantern/flashlight/client/reverseproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ func (client *Client) newReverseProxy(bal *balancer.Balancer) *httputil.ReverseP
// field when upstream servers are trying to determine the client IP.
// We need to add also the X-Lantern-Device-Id field.
Director: func(req *http.Request) {
// Add back the Host header which was stripped by the ReverseProxy. This
// is needed for sites that do virtual hosting.
req.Header.Set("Host", req.Host)
Copy link
Contributor

Choose a reason for hiding this comment

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

It's definitely stripped before our Director function is called right @oxtoacart?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's stripped by the http.Server, which is using the ReverseProxy as a Handler, so by the time it gets to the ReverseProxy's logic, the header is already gone.

req.Header.Set("X-LANTERN-DEVICE-ID", client.cfg().DeviceID)
for _, authToken := range allAuthTokens {
req.Header.Add("X-LANTERN-AUTH-TOKEN", authToken)
Expand Down