mirror of
https://github.com/thib8956/nginx-proxy
synced 2025-07-02 23:05:46 +00:00
feat: Add support for HTTP keep-alive between the proxy and upstream
This commit is contained in:
31
test/test_keepalive.py
Normal file
31
test/test_keepalive.py
Normal 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)
|
Reference in New Issue
Block a user