From 183968394ef842165c3e10a967add53452189b2c Mon Sep 17 00:00:00 2001 From: Frank Bille-Stauner Date: Sat, 22 Jul 2017 22:56:07 +0200 Subject: [PATCH 1/2] Use X-Forwared-Host for resolving host X-Forwarded-For is normally used for getting the original client IP, whereas X-Forwarded-Host is normally used to get the original host requested by the client. X-Forwarded-For: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For X-Forwarded-Host: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host --- config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.go b/config.go index 8eb9c3b..fd327ad 100644 --- a/config.go +++ b/config.go @@ -29,7 +29,7 @@ func newLocation(config Config) *location { base: config.Base, headers: headers{ scheme: "X-Forwarded-Proto", - host: "X-Forwarded-For", + host: "X-Forwarded-Host", }, } } From 03bc4ad20437a145024eaac6d47b82ef0979e738 Mon Sep 17 00:00:00 2001 From: Frank Bille-Stauner Date: Sat, 22 Jul 2017 23:01:43 +0200 Subject: [PATCH 2/2] Make sure test passes after X-Forwarded-Host change --- location_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/location_test.go b/location_test.go index 757af98..eabd6f5 100644 --- a/location_test.go +++ b/location_test.go @@ -49,7 +49,7 @@ var tests = []struct { req: &http.Request{ Header: http.Header{ "X-Forwarded-Proto": {"https"}, - "X-Forwarded-For": {"bar.com"}, + "X-Forwarded-Host": {"bar.com"}, }, URL: &url.URL{}, },