Commit c2593815 authored by Max Heyer's avatar Max Heyer

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

parent 7f546e52
...@@ -448,6 +448,7 @@ func parseBlock(c *caddyfile.Dispenser, u *staticUpstream, hasSrv bool) error { ...@@ -448,6 +448,7 @@ func parseBlock(c *caddyfile.Dispenser, u *staticUpstream, hasSrv bool) error {
u.upstreamHeaders.Add("Host", "{host}") u.upstreamHeaders.Add("Host", "{host}")
u.upstreamHeaders.Add("X-Real-IP", "{remote}") u.upstreamHeaders.Add("X-Real-IP", "{remote}")
u.upstreamHeaders.Add("X-Forwarded-Proto", "{scheme}") u.upstreamHeaders.Add("X-Forwarded-Proto", "{scheme}")
u.upstreamHeaders.Add("X-Forwarded-Port", "{server_port}")
case "websocket": case "websocket":
u.upstreamHeaders.Add("Connection", "{>Connection}") u.upstreamHeaders.Add("Connection", "{>Connection}")
u.upstreamHeaders.Add("Upgrade", "{>Upgrade}") u.upstreamHeaders.Add("Upgrade", "{>Upgrade}")
......
...@@ -321,6 +321,10 @@ func TestParseBlockTransparent(t *testing.T) { ...@@ -321,6 +321,10 @@ func TestParseBlockTransparent(t *testing.T) {
if _, ok := headers["X-Forwarded-For"]; ok { if _, ok := headers["X-Forwarded-For"]; ok {
t.Errorf("Test %d: Found unexpected X-Forwarded-For header", i+1) 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)
}
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment