1
0
mirror of https://github.com/thib8956/nginx-proxy synced 2025-02-24 09:48:14 +00:00
nginx-proxy/test/test_ssl/test_nohttp.py
Richard Hansen 9b4bb07b34
fix: Don't create fallback http(s) server when http(s) disabled
Before, a fallback http server was created to handle requests for
unknown virtual hosts even when `HTTPS_METHOD=nohttp`.  (In this case,
all http vhosts would be unknown.)  Likewise, a catch-all fallback
https server was still created even if `HTTPS_METHOD=nohttps`.

Now the fallback servers are created only if needed.  This brings the
behavior in line with the documentation and user expectation.  It will
also make it easier to implement a planned feature: different servers
on different ports.
2023-02-04 18:59:38 -05:00

20 lines
718 B
Python

import pytest
import requests
def test_web2_http_is_connection_refused(docker_compose, nginxproxy):
with pytest.raises(requests.exceptions.RequestException, match="Connection refused"):
nginxproxy.get("http://web2.nginx-proxy.tld/")
def test_web2_https_is_forwarded(docker_compose, nginxproxy):
r = nginxproxy.get("https://web2.nginx-proxy.tld/port", allow_redirects=False)
assert r.status_code == 200
assert "answer from port 82\n" in r.text
def test_web2_HSTS_policy_is_active(docker_compose, nginxproxy):
r = nginxproxy.get("https://web2.nginx-proxy.tld/port", allow_redirects=False)
assert "answer from port 82\n" in r.text
assert "Strict-Transport-Security" in r.headers