outposts/proxy: add X-Forwarded-Host since Host now gets changed by the proxy

closes #2284

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2022-02-10 23:09:55 +01:00
parent cc42830e23
commit 1f838bb2aa
4 changed files with 10 additions and 0 deletions

View File

@ -73,6 +73,7 @@ func (a *Application) configureProxy() error {
func (a *Application) proxyModifyRequest(ou *url.URL) func(req *http.Request) {
return func(r *http.Request) {
r.Header.Set("X-Forwarded-Host", r.Host)
claims, _ := a.getClaims(r)
r.URL.Scheme = ou.Scheme
r.URL.Host = ou.Host

View File

@ -19,6 +19,7 @@ func TestProxy_ModifyRequest(t *testing.T) {
}
a.proxyModifyRequest(u)(req)
assert.Equal(t, "frontend", req.Header.Get("X-Forwarded-Host"))
assert.Equal(t, "/foo", req.URL.Path)
assert.Equal(t, "backend:8012", req.URL.Host)
assert.Equal(t, "backend:8012", req.Host)