You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
net/http/httputil: ReverseProxy
Currently it preserves HTTP request Host header.
However, this may cause problem for some servers complaining Host not match.
I suggest to have a option to change Host header
For example: A reverse proxy http://a.com/* -> http://192.168.1.123/*
The client sends HTTP request with header Host: a.com
After forwarding, the server expects HTTP request header Host: 192.168.1.123, so we need to change it.
Do you have an example that shows the target receives a different Host header? As the docs say, Request.URL.Host is the server to connect to, Request.Host is the value used for the Host header.
I believe this is also specifically tested for in this test. Note the checking of req.Host in the backend server to verify it stays the same as what was in the original request sent to the proxy.
Sorry, I misread. If you want to modify the Host header in this way you'll probably need to define your own ReverseProxy with a custom Director.
ianlancetaylor
changed the title
net/http/httputil: ReverseProxy can change Host header
net/http/httputil: permit ReverseProxy to change Host header
Feb 19, 2016
net/http/httputil: ReverseProxy
Currently it preserves HTTP request Host header.
However, this may cause problem for some servers complaining Host not match.
I suggest to have a option to change Host header
For example: A reverse proxy
http://a.com/*
->http://192.168.1.123/*
The client sends HTTP request with header
Host: a.com
After forwarding, the server expects HTTP request header
Host: 192.168.1.123
, so we need to change it.In https://github.com/golang/go/blob/master/src/net/http/httputil/reverseproxy.go
The text was updated successfully, but these errors were encountered: