Merge pull request #4956 from djboris9/proxy-protocol-port
Fix proxy protocol support for X-Forwarded-Port
This commit is contained in:
commit
2f8cbeb8fa
3 changed files with 7 additions and 2 deletions
|
@ -105,7 +105,6 @@ end
|
||||||
-- phases or redirection
|
-- phases or redirection
|
||||||
function _M.rewrite(location_config)
|
function _M.rewrite(location_config)
|
||||||
ngx.var.pass_access_scheme = ngx.var.scheme
|
ngx.var.pass_access_scheme = ngx.var.scheme
|
||||||
ngx.var.pass_server_port = ngx.var.server_port
|
|
||||||
ngx.var.best_http_host = ngx.var.http_host or ngx.var.host
|
ngx.var.best_http_host = ngx.var.http_host or ngx.var.host
|
||||||
|
|
||||||
if config.use_forwarded_headers then
|
if config.use_forwarded_headers then
|
||||||
|
|
|
@ -1021,7 +1021,13 @@ stream {
|
||||||
set $proxy_upstream_name {{ buildUpstreamName $location | quote }};
|
set $proxy_upstream_name {{ buildUpstreamName $location | quote }};
|
||||||
set $proxy_host $proxy_upstream_name;
|
set $proxy_host $proxy_upstream_name;
|
||||||
set $pass_access_scheme $scheme;
|
set $pass_access_scheme $scheme;
|
||||||
|
|
||||||
|
{{ if $all.Cfg.UseProxyProtocol }}
|
||||||
|
set $pass_server_port $proxy_protocol_server_port;
|
||||||
|
{{ else }}
|
||||||
set $pass_server_port $server_port;
|
set $pass_server_port $server_port;
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
set $best_http_host $http_host;
|
set $best_http_host $http_host;
|
||||||
set $pass_port $pass_server_port;
|
set $pass_port $pass_server_port;
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ var _ = framework.IngressNginxDescribe("Proxy Protocol", func() {
|
||||||
Expect(err).NotTo(HaveOccurred(), "unexpected error reading connection data")
|
Expect(err).NotTo(HaveOccurred(), "unexpected error reading connection data")
|
||||||
body := string(data)
|
body := string(data)
|
||||||
Expect(body).Should(ContainSubstring(fmt.Sprintf("host=%v", "proxy-protocol")))
|
Expect(body).Should(ContainSubstring(fmt.Sprintf("host=%v", "proxy-protocol")))
|
||||||
Expect(body).Should(ContainSubstring(fmt.Sprintf("x-forwarded-port=80")))
|
Expect(body).Should(ContainSubstring(fmt.Sprintf("x-forwarded-port=1234")))
|
||||||
Expect(body).Should(ContainSubstring(fmt.Sprintf("x-forwarded-for=192.168.0.1")))
|
Expect(body).Should(ContainSubstring(fmt.Sprintf("x-forwarded-for=192.168.0.1")))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue