make upstream keepalive work for http
This commit is contained in:
parent
2be92628b7
commit
6511fa9f58
1 changed files with 6 additions and 7 deletions
|
@ -244,16 +244,15 @@ http {
|
||||||
|
|
||||||
{{ buildResolvers $cfg.Resolver $cfg.DisableIpv6DNS }}
|
{{ buildResolvers $cfg.Resolver $cfg.DisableIpv6DNS }}
|
||||||
|
|
||||||
{{/* Whenever nginx proxies a request without a "Connection" header, the "Connection" header is set to "close" */}}
|
# See https://www.nginx.com/blog/websocket-nginx
|
||||||
{{/* when making the target request. This means that you cannot simply use */}}
|
|
||||||
{{/* "proxy_set_header Connection $http_connection" for WebSocket support because in this case, the */}}
|
|
||||||
{{/* "Connection" header would be set to "" whenever the original request did not have a "Connection" header, */}}
|
|
||||||
{{/* which would mean no "Connection" header would be in the target request. Since this would deviate from */}}
|
|
||||||
{{/* normal nginx behavior we have to use this approach. */}}
|
|
||||||
# Retain the default nginx handling of requests without a "Connection" header
|
|
||||||
map $http_upgrade $connection_upgrade {
|
map $http_upgrade $connection_upgrade {
|
||||||
default upgrade;
|
default upgrade;
|
||||||
|
{{ if (gt $cfg.UpstreamKeepaliveConnections 0) }}
|
||||||
|
# See http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive
|
||||||
|
'' '';
|
||||||
|
{{ else }}
|
||||||
'' close;
|
'' close;
|
||||||
|
{{ end }}
|
||||||
}
|
}
|
||||||
|
|
||||||
# The following is a sneaky way to do "set $the_real_ip $remote_addr"
|
# The following is a sneaky way to do "set $the_real_ip $remote_addr"
|
||||||
|
|
Loading…
Reference in a new issue