Add an option to enable XForwarded headers
This commit is contained in:
parent
2146852c48
commit
9801373b46
3 changed files with 12 additions and 6 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ masquerade:
|
|||
proxy:
|
||||
url: https://some.site.net
|
||||
rewriteHost: true
|
||||
enableXForwardedHeaders: true
|
||||
insecure: true
|
||||
string:
|
||||
content: aint nothin here
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue