test: Add test case for default app redirect
Co-authored-by: Jonathan Underwood <junderwood@bitcoinbank.co.jp>
This commit is contained in:
parent
913a2c3df5
commit
3d3acc0982
2 changed files with 36 additions and 0 deletions
18
test/test_virtual-path/test_forwarding.py
Normal file
18
test/test_virtual-path/test_forwarding.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
def test_root_redirects_to_web1(docker_compose, nginxproxy):
|
||||||
|
r = nginxproxy.get("http://www.nginx-proxy.tld/port", allow_redirects=False)
|
||||||
|
assert r.status_code == 301
|
||||||
|
assert "Location" in r.headers
|
||||||
|
assert "http://www.nginx-proxy.tld/web1/port" == r.headers['Location']
|
||||||
|
|
||||||
|
def test_direct_access(docker_compose, nginxproxy):
|
||||||
|
r = nginxproxy.get("http://www.nginx-proxy.tld/web1/port", allow_redirects=False)
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert "answer from port 81\n" in r.text
|
||||||
|
|
||||||
|
def test_root_is_forwarded(docker_compose, nginxproxy):
|
||||||
|
r = nginxproxy.get("http://www.nginx-proxy.tld/port", allow_redirects=True)
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert "answer from port 81\n" in r.text
|
||||||
|
|
18
test/test_virtual-path/test_forwarding.yml
Normal file
18
test/test_virtual-path/test_forwarding.yml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
web1:
|
||||||
|
image: web
|
||||||
|
expose:
|
||||||
|
- "81"
|
||||||
|
environment:
|
||||||
|
WEB_PORTS: "81"
|
||||||
|
VIRTUAL_HOST: "www.nginx-proxy.tld"
|
||||||
|
VIRTUAL_PATH: "/web1/"
|
||||||
|
VIRTUAL_DEST: "/"
|
||||||
|
|
||||||
|
sut:
|
||||||
|
image: nginxproxy/nginx-proxy:test
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||||
|
- ../lib/ssl/dhparam.pem:/etc/nginx/dhparam/dhparam.pem:ro
|
||||||
|
- ./certs:/etc/nginx/certs:ro
|
||||||
|
environment:
|
||||||
|
- DEFAULT_ROOT=301 http://$$host/web1$$request_uri
|
Loading…
Reference in a new issue