mirror of
https://github.com/thib8956/nginx-proxy
synced 2025-02-24 09:48:14 +00:00
Merge pull request #2343 from nginx-proxy/docker-compose-upgrade
test: replace python docker-compose with docker compose
This commit is contained in:
commit
f044423e4e
@ -73,7 +73,7 @@ services:
|
||||
```
|
||||
|
||||
```console
|
||||
docker-compose up
|
||||
docker compose up
|
||||
curl -H "Host: whoami.example" localhost
|
||||
```
|
||||
|
||||
@ -259,10 +259,10 @@ nginx-proxy can also be run as two separate containers using the [nginxproxy/doc
|
||||
|
||||
You may want to do this to prevent having the docker socket bound to a publicly exposed container service.
|
||||
|
||||
You can demo this pattern with docker-compose:
|
||||
You can demo this pattern with docker compose:
|
||||
|
||||
```console
|
||||
docker-compose --file docker-compose-separate-containers.yml up
|
||||
docker compose --file docker-compose-separate-containers.yml up
|
||||
curl -H "Host: whoami.example" localhost
|
||||
```
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
version: '2'
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
nginx:
|
||||
image: nginx
|
||||
|
@ -1,4 +1,5 @@
|
||||
version: '2'
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
nginx-proxy:
|
||||
image: nginxproxy/nginx-proxy
|
||||
|
@ -48,11 +48,11 @@ This test suite uses [pytest](http://doc.pytest.org/en/latest/). The [conftest.p
|
||||
|
||||
When using the `docker_compose` fixture in a test, pytest will try to find a yml file named after your test module filename. For instance, if your test module is `test_example.py`, then the `docker_compose` fixture will try to load a `test_example.yml` [docker compose file](https://docs.docker.com/compose/compose-file/).
|
||||
|
||||
Once the docker compose file found, the fixture will remove all containers, run `docker-compose up`, and finally your test will be executed.
|
||||
Once the docker compose file found, the fixture will remove all containers, run `docker compose up`, and finally your test will be executed.
|
||||
|
||||
The fixture will run the _docker-compose_ command with the `-f` option to load the given compose file. So you can test your docker compose file syntax by running it yourself with:
|
||||
The fixture will run the _docker compose_ command with the `-f` option to load the given compose file. So you can test your docker compose file syntax by running it yourself with:
|
||||
|
||||
docker-compose -f test_example.yml up -d
|
||||
docker compose -f test_example.yml up -d
|
||||
|
||||
In the case you are running pytest from within a docker container, the `docker_compose` fixture will make sure the container running pytest is attached to all docker networks. That way, your test will be able to reach any of them.
|
||||
|
||||
|
@ -301,19 +301,19 @@ def get_nginx_conf_from_container(container):
|
||||
|
||||
|
||||
def docker_compose_up(compose_file='docker-compose.yml'):
|
||||
logging.info(f'docker-compose -f {compose_file} up -d')
|
||||
logging.info(f'docker compose -f {compose_file} up -d')
|
||||
try:
|
||||
subprocess.check_output(shlex.split(f'docker-compose -f {compose_file} up -d'), stderr=subprocess.STDOUT)
|
||||
subprocess.check_output(shlex.split(f'docker compose -f {compose_file} up -d'), stderr=subprocess.STDOUT)
|
||||
except subprocess.CalledProcessError as e:
|
||||
pytest.fail(f"Error while runninng 'docker-compose -f {compose_file} up -d':\n{e.output}", pytrace=False)
|
||||
pytest.fail(f"Error while runninng 'docker compose -f {compose_file} up -d':\n{e.output}", pytrace=False)
|
||||
|
||||
|
||||
def docker_compose_down(compose_file='docker-compose.yml'):
|
||||
logging.info(f'docker-compose -f {compose_file} down -v')
|
||||
logging.info(f'docker compose -f {compose_file} down -v')
|
||||
try:
|
||||
subprocess.check_output(shlex.split(f'docker-compose -f {compose_file} down -v'), stderr=subprocess.STDOUT)
|
||||
subprocess.check_output(shlex.split(f'docker compose -f {compose_file} down -v'), stderr=subprocess.STDOUT)
|
||||
except subprocess.CalledProcessError as e:
|
||||
pytest.fail(f"Error while runninng 'docker-compose -f {compose_file} down -v':\n{e.output}", pytrace=False)
|
||||
pytest.fail(f"Error while runninng 'docker compose -f {compose_file} down -v':\n{e.output}", pytrace=False)
|
||||
|
||||
|
||||
def wait_for_nginxproxy_to_be_ready():
|
||||
@ -333,7 +333,7 @@ def wait_for_nginxproxy_to_be_ready():
|
||||
|
||||
@pytest.fixture
|
||||
def docker_compose_file(request):
|
||||
"""Fixture naming the docker-compose file to consider.
|
||||
"""Fixture naming the docker compose file to consider.
|
||||
|
||||
If a YAML file exists with the same name as the test module (with the `.py` extension replaced
|
||||
with `.yml` or `.yaml`), use that. Otherwise, use `docker-compose.yml` in the same directory
|
||||
@ -354,7 +354,7 @@ def docker_compose_file(request):
|
||||
docker_compose_file = default_file
|
||||
|
||||
if not os.path.isfile(docker_compose_file):
|
||||
logging.error("Could not find any docker-compose file named either '{0}.yml', '{0}.yaml' or 'docker-compose.yml'".format(request.module.__name__))
|
||||
logging.error("Could not find any docker compose file named either '{0}.yml', '{0}.yaml' or 'docker-compose.yml'".format(request.module.__name__))
|
||||
|
||||
logging.debug(f"using docker compose file {docker_compose_file}")
|
||||
return docker_compose_file
|
||||
|
@ -19,8 +19,8 @@ docker build --pull -t nginx-proxy-tester \
|
||||
"${TESTDIR}/requirements" \
|
||||
|| exit 1
|
||||
|
||||
# run the nginx-proxy-tester container setting the correct value for the working dir in order for
|
||||
# docker-compose to work properly when run from within that container.
|
||||
# run the nginx-proxy-tester container setting the correct value for the working dir
|
||||
# in order for docker compose to work properly when run from within that container.
|
||||
exec docker run --rm -it --name "nginx-proxy-pytest" \
|
||||
--volume "/var/run/docker.sock:/var/run/docker.sock" \
|
||||
--volume "${DIR}:${DIR}" \
|
||||
|
@ -1,5 +1,4 @@
|
||||
backoff==2.2.1
|
||||
docker-compose==1.29.2
|
||||
docker==6.1.3
|
||||
pytest==7.4.3
|
||||
requests==2.31.0
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web:
|
||||
image: web
|
||||
expose:
|
||||
@ -6,7 +9,6 @@ web:
|
||||
WEB_PORTS: 81
|
||||
VIRTUAL_HOST: web.nginx-proxy
|
||||
|
||||
|
||||
reverseproxy:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
container_name: reverseproxy
|
||||
|
@ -32,4 +32,3 @@ services:
|
||||
environment:
|
||||
WEB_PORTS: 82
|
||||
VIRTUAL_HOST: webB.nginx-proxy
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web1:
|
||||
image: web
|
||||
expose:
|
||||
@ -14,7 +17,6 @@ web2:
|
||||
WEB_PORTS: 82
|
||||
VIRTUAL_HOST: web2.nginx-proxy.tld
|
||||
|
||||
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
|
@ -1,4 +1,5 @@
|
||||
version: '2'
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
nginx-proxy:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
nginx-proxy:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
|
@ -1,4 +1,5 @@
|
||||
version: '2'
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
nginx-proxy:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
|
@ -1,4 +1,5 @@
|
||||
version: '2'
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
nginx-proxy:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
|
@ -1,4 +1,5 @@
|
||||
version: '2'
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
nginx-proxy:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
|
@ -1,4 +1,5 @@
|
||||
version: '2'
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
nginx-proxy:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
# GIVEN a webserver with VIRTUAL_HOST set to web1.tld
|
||||
web1:
|
||||
image: web
|
||||
@ -7,7 +10,6 @@ web1:
|
||||
WEB_PORTS: 81
|
||||
VIRTUAL_HOST: web1.tld
|
||||
|
||||
|
||||
# WHEN nginx-proxy runs with DEFAULT_HOST set to web1.tld
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
|
@ -1,3 +1,5 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
@ -5,6 +7,7 @@ services:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
environment:
|
||||
DEFAULT_ROOT: none
|
||||
|
||||
web:
|
||||
image: web
|
||||
expose:
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: '2'
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
nginx:
|
||||
|
@ -1,4 +1,5 @@
|
||||
version: '3'
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
nginx:
|
||||
image: nginx
|
||||
|
@ -22,6 +22,7 @@ def web1(docker_compose):
|
||||
},
|
||||
ports={"81/tcp": None}
|
||||
)
|
||||
docker_compose.networks.get("test_default").connect(container)
|
||||
sleep(2) # give it some time to initialize and for docker-gen to detect it
|
||||
yield container
|
||||
try:
|
||||
@ -46,6 +47,7 @@ def web2(docker_compose):
|
||||
},
|
||||
ports={"82/tcp": None}
|
||||
)
|
||||
docker_compose.networks.get("test_default").connect(container)
|
||||
sleep(2) # give it some time to initialize and for docker-gen to detect it
|
||||
yield container
|
||||
try:
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
nginxproxy:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
|
@ -1,9 +1,12 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
- ./custom-fallback.conf:/etc/nginx/conf.d/zzz-custom-fallback.conf:ro
|
||||
|
||||
http-only:
|
||||
image: web
|
||||
expose:
|
||||
|
@ -1,9 +1,12 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
- ./nodefault.certs:/etc/nginx/certs:ro
|
||||
|
||||
https-and-http:
|
||||
image: web
|
||||
expose:
|
||||
@ -11,6 +14,7 @@ services:
|
||||
environment:
|
||||
WEB_PORTS: "81"
|
||||
VIRTUAL_HOST: https-and-http.nginx-proxy.test
|
||||
|
||||
https-only:
|
||||
image: web
|
||||
expose:
|
||||
@ -19,6 +23,7 @@ services:
|
||||
WEB_PORTS: "82"
|
||||
VIRTUAL_HOST: https-only.nginx-proxy.test
|
||||
HTTPS_METHOD: nohttp
|
||||
|
||||
http-only:
|
||||
image: web
|
||||
expose:
|
||||
@ -27,6 +32,7 @@ services:
|
||||
WEB_PORTS: "83"
|
||||
VIRTUAL_HOST: http-only.nginx-proxy.test
|
||||
HTTPS_METHOD: nohttps
|
||||
|
||||
missing-cert:
|
||||
image: web
|
||||
expose:
|
||||
|
@ -1,3 +1,5 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
@ -6,6 +8,7 @@ services:
|
||||
- ./withdefault.certs:/etc/nginx/certs:ro
|
||||
environment:
|
||||
HTTPS_METHOD: redirect
|
||||
|
||||
https-only:
|
||||
image: web
|
||||
expose:
|
||||
|
@ -1,3 +1,5 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
@ -6,6 +8,7 @@ services:
|
||||
- ./withdefault.certs:/etc/nginx/certs:ro
|
||||
environment:
|
||||
HTTPS_METHOD: nohttp
|
||||
|
||||
https-only:
|
||||
image: web
|
||||
expose:
|
||||
@ -13,6 +16,7 @@ services:
|
||||
environment:
|
||||
WEB_PORTS: "82"
|
||||
VIRTUAL_HOST: https-only.nginx-proxy.test
|
||||
|
||||
missing-cert:
|
||||
image: web
|
||||
expose:
|
||||
|
@ -1,3 +1,5 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
@ -6,6 +8,7 @@ services:
|
||||
- ./withdefault.certs:/etc/nginx/certs:ro
|
||||
environment:
|
||||
HTTPS_METHOD: nohttp
|
||||
|
||||
https-only:
|
||||
image: web
|
||||
expose:
|
||||
|
@ -1,3 +1,5 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
@ -5,6 +7,7 @@ services:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
environment:
|
||||
HTTPS_METHOD: redirect
|
||||
|
||||
http-only:
|
||||
image: web
|
||||
expose:
|
||||
|
@ -1,3 +1,5 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
@ -5,6 +7,7 @@ services:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
environment:
|
||||
HTTPS_METHOD: nohttps
|
||||
|
||||
http-only:
|
||||
image: web
|
||||
expose:
|
||||
|
@ -1,9 +1,12 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
- ./withdefault.certs:/etc/nginx/certs:ro
|
||||
|
||||
https-and-http:
|
||||
image: web
|
||||
expose:
|
||||
@ -11,6 +14,7 @@ services:
|
||||
environment:
|
||||
WEB_PORTS: "81"
|
||||
VIRTUAL_HOST: https-and-http.nginx-proxy.test
|
||||
|
||||
https-only:
|
||||
image: web
|
||||
expose:
|
||||
@ -19,6 +23,7 @@ services:
|
||||
WEB_PORTS: "82"
|
||||
VIRTUAL_HOST: https-only.nginx-proxy.test
|
||||
HTTPS_METHOD: nohttp
|
||||
|
||||
http-only:
|
||||
image: web
|
||||
expose:
|
||||
@ -27,6 +32,7 @@ services:
|
||||
WEB_PORTS: "83"
|
||||
VIRTUAL_HOST: http-only.nginx-proxy.test
|
||||
HTTPS_METHOD: nohttps
|
||||
|
||||
missing-cert:
|
||||
image: web
|
||||
expose:
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web:
|
||||
image: web
|
||||
expose:
|
||||
@ -15,7 +18,6 @@ web-server-tokens-off:
|
||||
VIRTUAL_HOST: web-server-tokens-off.nginx-proxy.tld
|
||||
SERVER_TOKENS: "off"
|
||||
|
||||
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web:
|
||||
image: web
|
||||
expose:
|
||||
@ -15,7 +18,6 @@ web-server-tokens-off:
|
||||
VIRTUAL_HOST: web-server-tokens-off.nginx-proxy.tld
|
||||
SERVER_TOKENS: "off"
|
||||
|
||||
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
|
@ -1,3 +1,5 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
http2-global-disabled:
|
||||
image: web
|
||||
|
@ -1,3 +1,5 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
http3-global-disabled:
|
||||
image: web
|
||||
|
@ -1,3 +1,5 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
http3-global-enabled:
|
||||
image: web
|
||||
|
@ -1,3 +1,5 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
http3-vhost-enabled:
|
||||
image: web
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web1:
|
||||
image: web
|
||||
expose:
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web1:
|
||||
image: web
|
||||
expose:
|
||||
@ -20,4 +23,3 @@ sut:
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
- ./network_internal.conf:/etc/nginx/network_internal.conf:ro
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web1:
|
||||
image: web
|
||||
expose:
|
||||
@ -24,4 +27,3 @@ sut:
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
- ./network_internal.conf:/etc/nginx/network_internal.conf:ro
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: '2'
|
||||
version: "2"
|
||||
|
||||
networks:
|
||||
net1:
|
||||
@ -28,7 +28,6 @@ services:
|
||||
networks:
|
||||
- net1
|
||||
|
||||
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
keepalive-disabled:
|
||||
image: web
|
||||
expose:
|
||||
@ -16,7 +19,6 @@ keepalive-enabled:
|
||||
labels:
|
||||
com.github.nginx-proxy.nginx-proxy.keepalive: "64"
|
||||
|
||||
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
|
@ -1,3 +1,5 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
loadbalance-hash:
|
||||
image: web
|
||||
|
@ -1,3 +1,5 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web1:
|
||||
image: web
|
||||
expose:
|
||||
@ -12,4 +15,4 @@ sut:
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
environment:
|
||||
LOG_FORMAT: "$$remote_addr - $$remote_user [$$time_local] \"$$request\" $$status $$body_bytes_sent \"$$http_referer\" \"$$http_user_agent\" request_time=$$request_time $$upstream_response_time"
|
||||
LOG_FORMAT: '$$remote_addr - $$remote_user [$$time_local] "$$request" $$status $$body_bytes_sent "$$http_referer" "$$http_user_agent" request_time=$$request_time $$upstream_response_time'
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web:
|
||||
image: web
|
||||
expose:
|
||||
@ -6,7 +9,6 @@ web:
|
||||
WEB_PORTS: 81
|
||||
VIRTUAL_HOST: webA.nginx-proxy.tld,webB.nginx-proxy.tld
|
||||
|
||||
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: '2'
|
||||
version: "2"
|
||||
|
||||
networks:
|
||||
net1: {}
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web:
|
||||
image: web
|
||||
expose:
|
||||
@ -7,7 +10,6 @@ web:
|
||||
VIRTUAL_HOST: "web.nginx-proxy.tld"
|
||||
VIRTUAL_PORT: "90"
|
||||
|
||||
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web:
|
||||
image: web
|
||||
expose:
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web:
|
||||
image: web
|
||||
expose:
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web:
|
||||
image: web
|
||||
expose:
|
||||
@ -6,7 +9,6 @@ web:
|
||||
WEB_PORTS: "81"
|
||||
VIRTUAL_HOST: "web.nginx-proxy.tld"
|
||||
|
||||
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: '2'
|
||||
version: "2"
|
||||
|
||||
networks:
|
||||
net1:
|
||||
@ -28,7 +28,6 @@ services:
|
||||
networks:
|
||||
- net1
|
||||
|
||||
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: '2'
|
||||
version: "2"
|
||||
|
||||
networks:
|
||||
net1:
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web1:
|
||||
image: web
|
||||
expose:
|
||||
@ -21,7 +24,7 @@ web3:
|
||||
environment:
|
||||
WEB_PORTS: 83
|
||||
VIRTUAL_HOST: web.nginx-proxy.tld
|
||||
net: "none"
|
||||
network_mode: "none"
|
||||
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web:
|
||||
image: web
|
||||
expose:
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web:
|
||||
image: web
|
||||
expose:
|
||||
@ -5,7 +8,7 @@ web:
|
||||
environment:
|
||||
WEB_PORTS: 81
|
||||
VIRTUAL_HOST: web.nginx-proxy.tld
|
||||
net: "none"
|
||||
network_mode: "none"
|
||||
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
|
@ -3,6 +3,7 @@ import subprocess
|
||||
|
||||
import backoff
|
||||
import docker
|
||||
import pprint
|
||||
import pytest
|
||||
|
||||
docker_client = docker.from_env()
|
||||
@ -60,7 +61,8 @@ def require_openssl(required_version):
|
||||
|
||||
@require_openssl("1.0.2")
|
||||
def negotiate_cipher(sut_container, additional_params='', grep='Cipher is'):
|
||||
host = f"{sut_container.attrs['NetworkSettings']['IPAddress']}:443"
|
||||
sut_container.reload()
|
||||
host = f"{sut_container.attrs['NetworkSettings']['Networks']['test_ssl_default']['IPAddress']}:443"
|
||||
|
||||
try:
|
||||
# Enforce TLS 1.2 as newer versions don't support custom dhparam or ciphersuite preference.
|
||||
@ -77,7 +79,7 @@ def negotiate_cipher(sut_container, additional_params='', grep='Cipher is'):
|
||||
except subprocess.CalledProcessError as e:
|
||||
# Output a more helpful error, the original exception in this case isn't that helpful.
|
||||
# `from None` to ignore undesired output from exception chaining.
|
||||
raise Exception("Failed to process CLI request:\n" + e.stderr) from None
|
||||
raise Exception(f"Failed to process CLI request openssl s_client -connect {host} -tls1_2 {additional_params}:\n" + e.stderr) from None
|
||||
|
||||
|
||||
# The default `dh_bits` can vary due to configuration.
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web5:
|
||||
image: web
|
||||
expose:
|
||||
@ -18,7 +21,6 @@ web2:
|
||||
WEB_PORTS: "85"
|
||||
VIRTUAL_HOST: "web2.nginx-proxy.tld"
|
||||
|
||||
|
||||
# sut - System Under Test
|
||||
# `docker.sock` required for functionality
|
||||
# `certs` required to enable HTTPS via template
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web1:
|
||||
image: web
|
||||
expose:
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web1:
|
||||
image: web
|
||||
expose:
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web2:
|
||||
image: web
|
||||
expose:
|
||||
@ -7,7 +10,6 @@ web2:
|
||||
VIRTUAL_HOST: "web2.nginx-proxy.tld"
|
||||
HTTPS_METHOD: nohttp
|
||||
|
||||
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web:
|
||||
image: web
|
||||
expose:
|
||||
@ -7,7 +10,6 @@ web:
|
||||
VIRTUAL_HOST: "web.nginx-proxy.tld"
|
||||
HTTPS_METHOD: nohttps
|
||||
|
||||
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web3:
|
||||
image: web
|
||||
expose:
|
||||
@ -7,7 +10,6 @@ web3:
|
||||
VIRTUAL_HOST: "web3.nginx-proxy.tld"
|
||||
HTTPS_METHOD: noredirect
|
||||
|
||||
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web1:
|
||||
image: web
|
||||
expose:
|
||||
@ -23,4 +26,3 @@ sut:
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
- ./certs:/etc/nginx/certs:ro
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web1:
|
||||
image: web
|
||||
expose:
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web:
|
||||
image: web
|
||||
expose:
|
||||
@ -7,7 +10,6 @@ web:
|
||||
VIRTUAL_HOST: web.nginx-proxy.tld
|
||||
HTTPS_METHOD: noredirect
|
||||
|
||||
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web:
|
||||
image: web
|
||||
expose:
|
||||
@ -7,7 +10,6 @@ web:
|
||||
VIRTUAL_HOST: web.nginx-proxy.tld
|
||||
HTTPS_METHOD: noredirect
|
||||
|
||||
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
environment:
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web:
|
||||
image: web
|
||||
expose:
|
||||
@ -7,7 +10,6 @@ web:
|
||||
VIRTUAL_HOST: web.nginx-proxy.tld
|
||||
HTTPS_METHOD: noredirect
|
||||
|
||||
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
environment:
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: '2'
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web:
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: '2'
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web:
|
||||
|
@ -1,8 +1,11 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
|
||||
web1:
|
||||
image: web
|
||||
expose:
|
||||
@ -11,6 +14,7 @@ services:
|
||||
WEB_PORTS: "81"
|
||||
# The space is intentional (should be trimmed).
|
||||
VIRTUAL_HOST: " "
|
||||
|
||||
web2:
|
||||
image: web
|
||||
expose:
|
||||
@ -19,6 +23,7 @@ services:
|
||||
WEB_PORTS: "82"
|
||||
# The space is intentional (should be trimmed).
|
||||
VIRTUAL_HOST: "web2.nginx-proxy.test ,"
|
||||
|
||||
web3:
|
||||
image: web
|
||||
expose:
|
||||
@ -27,6 +32,7 @@ services:
|
||||
WEB_PORTS: "83"
|
||||
# The space is intentional (should be trimmed).
|
||||
VIRTUAL_HOST: " ,web3.nginx-proxy.test"
|
||||
|
||||
web4:
|
||||
image: web
|
||||
expose:
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: '2'
|
||||
version: "2"
|
||||
|
||||
networks:
|
||||
net1: {}
|
||||
|
@ -1,4 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
foo:
|
||||
image: web
|
||||
expose:
|
||||
@ -45,4 +47,3 @@ sut:
|
||||
- ./foo.conf:/etc/nginx/vhost.d/foo.nginx-proxy.test:ro
|
||||
- ./bar.conf:/etc/nginx/vhost.d/nginx-proxy.test_918d687a929083edd0c7224ee2293e0e7c062ab4_location:ro
|
||||
- ./alternate.conf:/etc/nginx/vhost.d/nginx-proxy.test_7fb22b74bbdf907425dbbad18e4462565cada230_location:ro
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web1:
|
||||
image: web
|
||||
expose:
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web1:
|
||||
image: web
|
||||
expose:
|
||||
|
@ -39,6 +39,7 @@ def web4(docker_compose):
|
||||
},
|
||||
ports={"84/tcp": None}
|
||||
)
|
||||
docker_compose.networks.get("test_virtual-path_default").connect(container)
|
||||
sleep(2) # give it some time to initialize and for docker-gen to detect it
|
||||
yield container
|
||||
try:
|
||||
|
@ -1,4 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
foo:
|
||||
image: web
|
||||
expose:
|
||||
|
@ -1,3 +1,6 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
web1:
|
||||
image: web
|
||||
expose:
|
||||
@ -28,8 +31,7 @@ web4:
|
||||
- "84"
|
||||
environment:
|
||||
WEB_PORTS: "84"
|
||||
VIRTUAL_HOST: ~^web4\..*\.nginx-proxy\.regexp$$ # we need to double the `$` because of docker-compose variable interpolation
|
||||
|
||||
VIRTUAL_HOST: ~^web4\..*\.nginx-proxy\.regexp$$ # we need to double the `$` because of docker compose variable interpolation
|
||||
|
||||
sut:
|
||||
image: nginxproxy/nginx-proxy:test
|
||||
|
Loading…
x
Reference in New Issue
Block a user