0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2025-01-13 22:51:08 -05:00

Add header X-Forwarded-Port with placeholder {server_port} to preset proxy preset transparent

This commit is contained in:
Max Heyer 2019-01-26 00:36:36 +01:00
parent 7f546e529e
commit c259381541
2 changed files with 5 additions and 0 deletions

View file

@ -448,6 +448,7 @@ func parseBlock(c *caddyfile.Dispenser, u *staticUpstream, hasSrv bool) error {
u.upstreamHeaders.Add("Host", "{host}")
u.upstreamHeaders.Add("X-Real-IP", "{remote}")
u.upstreamHeaders.Add("X-Forwarded-Proto", "{scheme}")
u.upstreamHeaders.Add("X-Forwarded-Port", "{server_port}")
case "websocket":
u.upstreamHeaders.Add("Connection", "{>Connection}")
u.upstreamHeaders.Add("Upgrade", "{>Upgrade}")

View file

@ -321,6 +321,10 @@ func TestParseBlockTransparent(t *testing.T) {
if _, ok := headers["X-Forwarded-For"]; ok {
t.Errorf("Test %d: Found unexpected X-Forwarded-For header", i+1)
}
if _, ok := headers["X-Forwarded-Port"]; !ok {
t.Errorf("Test %d: Could not find the X-Forwarded-Port header", i+1)
}
}
}
}