Skip to content

Commit

Permalink
Merge pull request #3098 from ElvinEfendi/make-keepalive-work
Browse files Browse the repository at this point in the history
make upstream keepalive work for http
  • Loading branch information
k8s-ci-robot authored Sep 15, 2018
2 parents 80933bc + 6511fa9 commit 6ed5c95
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions rootfs/etc/nginx/template/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,15 @@ http {

{{ buildResolvers $cfg.Resolver $cfg.DisableIpv6DNS }}

{{/* Whenever nginx proxies a request without a "Connection" header, the "Connection" header is set to "close" */}}
{{/* 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
# See https://www.nginx.com/blog/websocket-nginx
map $http_upgrade $connection_upgrade {
default upgrade;
{{ if (gt $cfg.UpstreamKeepaliveConnections 0) }}
# See http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive
'' '';
{{ else }}
'' close;
{{ end }}
}

# The following is a sneaky way to do "set $the_real_ip $remote_addr"
Expand Down

0 comments on commit 6ed5c95

Please sign in to comment.