diff --git a/app/cmd/server.go b/app/cmd/server.go index e2d2a57..85e303b 100644 --- a/app/cmd/server.go +++ b/app/cmd/server.go @@ -238,9 +238,10 @@ type serverConfigMasqueradeFile struct { } type serverConfigMasqueradeProxy struct { - URL string `mapstructure:"url"` - RewriteHost bool `mapstructure:"rewriteHost"` - Insecure bool `mapstructure:"insecure"` + URL string `mapstructure:"url"` + RewriteHost bool `mapstructure:"rewriteHost"` + EnableXForwardedHeaders bool `mapstructure:"enableXForwardedHeaders"` + Insecure bool `mapstructure:"insecure"` } type serverConfigMasqueradeString struct { @@ -852,6 +853,9 @@ func (c *serverConfig) fillMasqHandler(hyConfig *server.Config) error { if !c.Masquerade.Proxy.RewriteHost { r.Out.Host = r.In.Host } + if c.Masquerade.Proxy.EnableXForwardedHeaders { + r.SetXForwarded() + } }, Transport: transport, ErrorHandler: func(w http.ResponseWriter, r *http.Request, err error) { diff --git a/app/cmd/server_test.go b/app/cmd/server_test.go index b2e3a77..b476478 100644 --- a/app/cmd/server_test.go +++ b/app/cmd/server_test.go @@ -170,9 +170,10 @@ func TestServerConfig(t *testing.T) { Dir: "/www/masq", }, Proxy: serverConfigMasqueradeProxy{ - URL: "https://some.site.net", - RewriteHost: true, - Insecure: true, + URL: "https://some.site.net", + RewriteHost: true, + EnableXForwardedHeaders: true, + Insecure: true, }, String: serverConfigMasqueradeString{ Content: "aint nothin here", diff --git a/app/cmd/server_test.yaml b/app/cmd/server_test.yaml index 0aa9e3f..925d1e6 100644 --- a/app/cmd/server_test.yaml +++ b/app/cmd/server_test.yaml @@ -133,6 +133,7 @@ masquerade: proxy: url: https://some.site.net rewriteHost: true + enableXForwardedHeaders: true insecure: true string: content: aint nothin here