1
0
mirror of https://github.com/thib8956/nginx-proxy synced 2025-07-01 14:25:46 +00:00

feat: Add support for HTTP keep-alive between the proxy and upstream

This commit is contained in:
Richard Hansen
2022-03-28 02:56:36 -04:00
parent 1f855fc7b3
commit 49bb37dfdb
4 changed files with 98 additions and 4 deletions

31
test/test_keepalive.py Normal file
View File

@ -0,0 +1,31 @@
import re
def test_keepalive_disabled(docker_compose, nginxproxy):
r = nginxproxy.get("http://keepalive-disabled.nginx-proxy.test/headers")
assert r.status_code == 200
assert re.search(fr'(?m)^(?i:Connection): close$', r.text)
def test_keepalive_disabled_other_headers_ok(docker_compose, nginxproxy):
"""Make sure the other proxy_set_header headers are still set.
According to the nginx docs [1], any proxy_set_header directive in a block
disables inheritance of proxy_set_header directives in a parent block. Make
sure that doesn't happen.
[1] https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_set_header
"""
r = nginxproxy.get("http://keepalive-disabled.nginx-proxy.test/headers")
assert r.status_code == 200
assert re.search(fr'(?m)^(?i:X-Real-IP): ', r.text)
def test_keepalive_enabled(docker_compose, nginxproxy):
r = nginxproxy.get("http://keepalive-enabled.nginx-proxy.test/headers")
assert r.status_code == 200
assert not re.search(fr'(?m)^(?i:Connection):', r.text)
def test_keepalive_enabled_other_headers_ok(docker_compose, nginxproxy):
"""See the docstring for the disabled case above."""
r = nginxproxy.get("http://keepalive-enabled.nginx-proxy.test/headers")
assert r.status_code == 200
assert re.search(fr'(?m)^(?i:X-Real-IP): ', r.text)

25
test/test_keepalive.yml Normal file
View File

@ -0,0 +1,25 @@
keepalive-disabled:
image: web
expose:
- "80"
environment:
WEB_PORTS: 80
VIRTUAL_HOST: keepalive-disabled.nginx-proxy.test
keepalive-enabled:
image: web
expose:
- "80"
environment:
WEB_PORTS: 80
VIRTUAL_HOST: keepalive-enabled.nginx-proxy.test
labels:
com.github.nginx-proxy.nginx-proxy.keepalive: "64"
sut:
image: nginxproxy/nginx-proxy:test
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
environment:
HTTPS_METHOD: nohttps