1
0
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:
Nicolas Duchon 2023-12-12 22:07:14 +01:00 committed by GitHub
commit f044423e4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
77 changed files with 917 additions and 771 deletions

View File

@ -73,7 +73,7 @@ services:
``` ```
```console ```console
docker-compose up docker compose up
curl -H "Host: whoami.example" localhost 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 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 ```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 curl -H "Host: whoami.example" localhost
``` ```

View File

@ -1,4 +1,5 @@
version: '2' version: "2"
services: services:
nginx: nginx:
image: nginx image: nginx

View File

@ -1,4 +1,5 @@
version: '2' version: "2"
services: services:
nginx-proxy: nginx-proxy:
image: nginxproxy/nginx-proxy image: nginxproxy/nginx-proxy

View File

@ -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/). 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. 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.

View File

@ -301,19 +301,19 @@ def get_nginx_conf_from_container(container):
def docker_compose_up(compose_file='docker-compose.yml'): 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: 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: 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'): 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: 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: 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(): def wait_for_nginxproxy_to_be_ready():
@ -333,7 +333,7 @@ def wait_for_nginxproxy_to_be_ready():
@pytest.fixture @pytest.fixture
def docker_compose_file(request): 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 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 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 docker_compose_file = default_file
if not os.path.isfile(docker_compose_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}") logging.debug(f"using docker compose file {docker_compose_file}")
return docker_compose_file return docker_compose_file

View File

@ -19,8 +19,8 @@ docker build --pull -t nginx-proxy-tester \
"${TESTDIR}/requirements" \ "${TESTDIR}/requirements" \
|| exit 1 || exit 1
# run the nginx-proxy-tester container setting the correct value for the working dir in order for # run the nginx-proxy-tester container setting the correct value for the working dir
# docker-compose to work properly when run from within that container. # in order for docker compose to work properly when run from within that container.
exec docker run --rm -it --name "nginx-proxy-pytest" \ exec docker run --rm -it --name "nginx-proxy-pytest" \
--volume "/var/run/docker.sock:/var/run/docker.sock" \ --volume "/var/run/docker.sock:/var/run/docker.sock" \
--volume "${DIR}:${DIR}" \ --volume "${DIR}:${DIR}" \

View File

@ -1,5 +1,4 @@
backoff==2.2.1 backoff==2.2.1
docker-compose==1.29.2
docker==6.1.3 docker==6.1.3
pytest==7.4.3 pytest==7.4.3
requests==2.31.0 requests==2.31.0

View File

@ -1,15 +1,17 @@
web: version: "2"
image: web
expose:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: web.nginx-proxy
services:
web:
image: web
expose:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: web.nginx-proxy
reverseproxy: reverseproxy:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
container_name: reverseproxy container_name: reverseproxy
volumes: volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro
- ./tmp_certs:/etc/nginx/certs:ro - ./tmp_certs:/etc/nginx/certs:ro

View File

@ -32,4 +32,3 @@ services:
environment: environment:
WEB_PORTS: 82 WEB_PORTS: 82
VIRTUAL_HOST: webB.nginx-proxy VIRTUAL_HOST: webB.nginx-proxy

View File

@ -1,23 +1,25 @@
web1: version: "2"
image: web
expose:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: web1.nginx-proxy.tld
web2: services:
image: web web1:
expose: image: web
- "82" expose:
environment: - "81"
WEB_PORTS: 82 environment:
VIRTUAL_HOST: web2.nginx-proxy.tld WEB_PORTS: 81
VIRTUAL_HOST: web1.nginx-proxy.tld
web2:
image: web
expose:
- "82"
environment:
WEB_PORTS: 82
VIRTUAL_HOST: web2.nginx-proxy.tld
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
volumes: volumes:
- /var/run/docker.sock:/f00.sock:ro - /var/run/docker.sock:/f00.sock:ro
environment: environment:
DOCKER_HOST: unix:///f00.sock DOCKER_HOST: unix:///f00.sock

View File

@ -1,4 +1,5 @@
version: '2' version: "2"
services: services:
nginx-proxy: nginx-proxy:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test

View File

@ -1,30 +1,33 @@
nginx-proxy: version: "2"
image: nginxproxy/nginx-proxy:test
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./my_custom_proxy_settings.conf:/etc/nginx/vhost.d/default_location:ro
- ./my_custom_proxy_settings_bar.conf:/etc/nginx/vhost.d/web3.nginx-proxy.example_location:ro
web1: services:
image: web nginx-proxy:
expose: image: nginxproxy/nginx-proxy:test
- "81" volumes:
environment: - /var/run/docker.sock:/tmp/docker.sock:ro
WEB_PORTS: 81 - ./my_custom_proxy_settings.conf:/etc/nginx/vhost.d/default_location:ro
VIRTUAL_HOST: web1.nginx-proxy.example - ./my_custom_proxy_settings_bar.conf:/etc/nginx/vhost.d/web3.nginx-proxy.example_location:ro
web2: web1:
image: web image: web
expose: expose:
- "82" - "81"
environment: environment:
WEB_PORTS: 82 WEB_PORTS: 81
VIRTUAL_HOST: web2.nginx-proxy.example VIRTUAL_HOST: web1.nginx-proxy.example
web3: web2:
image: web image: web
expose: expose:
- "83" - "82"
environment: environment:
WEB_PORTS: 83 WEB_PORTS: 82
VIRTUAL_HOST: web3.nginx-proxy.example VIRTUAL_HOST: web2.nginx-proxy.example
web3:
image: web
expose:
- "83"
environment:
WEB_PORTS: 83
VIRTUAL_HOST: web3.nginx-proxy.example

View File

@ -1,4 +1,5 @@
version: '2' version: "2"
services: services:
nginx-proxy: nginx-proxy:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test

View File

@ -1,4 +1,5 @@
version: '2' version: "2"
services: services:
nginx-proxy: nginx-proxy:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test

View File

@ -1,4 +1,5 @@
version: '2' version: "2"
services: services:
nginx-proxy: nginx-proxy:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test

View File

@ -1,4 +1,5 @@
version: '2' version: "2"
services: services:
nginx-proxy: nginx-proxy:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test

View File

@ -1,17 +1,19 @@
# GIVEN a webserver with VIRTUAL_HOST set to web1.tld version: "2"
web1:
image: web
expose:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: web1.tld
services:
# GIVEN a webserver with VIRTUAL_HOST set to web1.tld
web1:
image: web
expose:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: web1.tld
# WHEN nginx-proxy runs with DEFAULT_HOST set to web1.tld # WHEN nginx-proxy runs with DEFAULT_HOST set to web1.tld
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
volumes: volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro
environment: environment:
DEFAULT_HOST: web1.tld DEFAULT_HOST: web1.tld

View File

@ -1,3 +1,5 @@
version: "2"
services: services:
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
@ -5,6 +7,7 @@ services:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro
environment: environment:
DEFAULT_ROOT: none DEFAULT_ROOT: none
web: web:
image: web image: web
expose: expose:

View File

@ -1,4 +1,4 @@
version: '2' version: "2"
services: services:
nginx: nginx:

View File

@ -1,4 +1,5 @@
version: '3' version: "3"
services: services:
nginx: nginx:
image: nginx image: nginx

View File

@ -22,6 +22,7 @@ def web1(docker_compose):
}, },
ports={"81/tcp": None} 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 sleep(2) # give it some time to initialize and for docker-gen to detect it
yield container yield container
try: try:
@ -46,6 +47,7 @@ def web2(docker_compose):
}, },
ports={"82/tcp": None} 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 sleep(2) # give it some time to initialize and for docker-gen to detect it
yield container yield container
try: try:

View File

@ -1,4 +1,7 @@
nginxproxy: version: "2"
image: nginxproxy/nginx-proxy:test
volumes: services:
- /var/run/docker.sock:/tmp/docker.sock:ro nginxproxy:
image: nginxproxy/nginx-proxy:test
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro

View File

@ -1,9 +1,12 @@
version: "2"
services: services:
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
volumes: volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro
- ./custom-fallback.conf:/etc/nginx/conf.d/zzz-custom-fallback.conf:ro - ./custom-fallback.conf:/etc/nginx/conf.d/zzz-custom-fallback.conf:ro
http-only: http-only:
image: web image: web
expose: expose:

View File

@ -1,9 +1,12 @@
version: "2"
services: services:
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
volumes: volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro
- ./nodefault.certs:/etc/nginx/certs:ro - ./nodefault.certs:/etc/nginx/certs:ro
https-and-http: https-and-http:
image: web image: web
expose: expose:
@ -11,6 +14,7 @@ services:
environment: environment:
WEB_PORTS: "81" WEB_PORTS: "81"
VIRTUAL_HOST: https-and-http.nginx-proxy.test VIRTUAL_HOST: https-and-http.nginx-proxy.test
https-only: https-only:
image: web image: web
expose: expose:
@ -19,6 +23,7 @@ services:
WEB_PORTS: "82" WEB_PORTS: "82"
VIRTUAL_HOST: https-only.nginx-proxy.test VIRTUAL_HOST: https-only.nginx-proxy.test
HTTPS_METHOD: nohttp HTTPS_METHOD: nohttp
http-only: http-only:
image: web image: web
expose: expose:
@ -27,6 +32,7 @@ services:
WEB_PORTS: "83" WEB_PORTS: "83"
VIRTUAL_HOST: http-only.nginx-proxy.test VIRTUAL_HOST: http-only.nginx-proxy.test
HTTPS_METHOD: nohttps HTTPS_METHOD: nohttps
missing-cert: missing-cert:
image: web image: web
expose: expose:

View File

@ -1,3 +1,5 @@
version: "2"
services: services:
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
@ -6,6 +8,7 @@ services:
- ./withdefault.certs:/etc/nginx/certs:ro - ./withdefault.certs:/etc/nginx/certs:ro
environment: environment:
HTTPS_METHOD: redirect HTTPS_METHOD: redirect
https-only: https-only:
image: web image: web
expose: expose:

View File

@ -1,3 +1,5 @@
version: "2"
services: services:
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
@ -6,6 +8,7 @@ services:
- ./withdefault.certs:/etc/nginx/certs:ro - ./withdefault.certs:/etc/nginx/certs:ro
environment: environment:
HTTPS_METHOD: nohttp HTTPS_METHOD: nohttp
https-only: https-only:
image: web image: web
expose: expose:
@ -13,6 +16,7 @@ services:
environment: environment:
WEB_PORTS: "82" WEB_PORTS: "82"
VIRTUAL_HOST: https-only.nginx-proxy.test VIRTUAL_HOST: https-only.nginx-proxy.test
missing-cert: missing-cert:
image: web image: web
expose: expose:

View File

@ -1,3 +1,5 @@
version: "2"
services: services:
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
@ -6,6 +8,7 @@ services:
- ./withdefault.certs:/etc/nginx/certs:ro - ./withdefault.certs:/etc/nginx/certs:ro
environment: environment:
HTTPS_METHOD: nohttp HTTPS_METHOD: nohttp
https-only: https-only:
image: web image: web
expose: expose:

View File

@ -1,3 +1,5 @@
version: "2"
services: services:
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
@ -5,6 +7,7 @@ services:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro
environment: environment:
HTTPS_METHOD: redirect HTTPS_METHOD: redirect
http-only: http-only:
image: web image: web
expose: expose:

View File

@ -1,3 +1,5 @@
version: "2"
services: services:
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
@ -5,6 +7,7 @@ services:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro
environment: environment:
HTTPS_METHOD: nohttps HTTPS_METHOD: nohttps
http-only: http-only:
image: web image: web
expose: expose:

View File

@ -1,9 +1,12 @@
version: "2"
services: services:
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
volumes: volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro
- ./withdefault.certs:/etc/nginx/certs:ro - ./withdefault.certs:/etc/nginx/certs:ro
https-and-http: https-and-http:
image: web image: web
expose: expose:
@ -11,6 +14,7 @@ services:
environment: environment:
WEB_PORTS: "81" WEB_PORTS: "81"
VIRTUAL_HOST: https-and-http.nginx-proxy.test VIRTUAL_HOST: https-and-http.nginx-proxy.test
https-only: https-only:
image: web image: web
expose: expose:
@ -19,6 +23,7 @@ services:
WEB_PORTS: "82" WEB_PORTS: "82"
VIRTUAL_HOST: https-only.nginx-proxy.test VIRTUAL_HOST: https-only.nginx-proxy.test
HTTPS_METHOD: nohttp HTTPS_METHOD: nohttp
http-only: http-only:
image: web image: web
expose: expose:
@ -27,6 +32,7 @@ services:
WEB_PORTS: "83" WEB_PORTS: "83"
VIRTUAL_HOST: http-only.nginx-proxy.test VIRTUAL_HOST: http-only.nginx-proxy.test
HTTPS_METHOD: nohttps HTTPS_METHOD: nohttps
missing-cert: missing-cert:
image: web image: web
expose: expose:

View File

@ -1,22 +1,24 @@
web: version: "2"
image: web
expose:
- "80"
environment:
WEB_PORTS: 80
VIRTUAL_HOST: web.nginx-proxy.tld
web-server-tokens-off: services:
image: web web:
expose: image: web
- "80" expose:
environment: - "80"
WEB_PORTS: 80 environment:
VIRTUAL_HOST: web-server-tokens-off.nginx-proxy.tld WEB_PORTS: 80
SERVER_TOKENS: "off" VIRTUAL_HOST: web.nginx-proxy.tld
web-server-tokens-off:
image: web
expose:
- "80"
environment:
WEB_PORTS: 80
VIRTUAL_HOST: web-server-tokens-off.nginx-proxy.tld
SERVER_TOKENS: "off"
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
volumes: volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro

View File

@ -1,28 +1,30 @@
web: version: "2"
image: web
expose:
- "80"
environment:
WEB_PORTS: 80
VIRTUAL_HOST: web.nginx-proxy.tld
web-server-tokens-off: services:
image: web web:
expose: image: web
- "80" expose:
environment: - "80"
WEB_PORTS: 80 environment:
VIRTUAL_HOST: web-server-tokens-off.nginx-proxy.tld WEB_PORTS: 80
SERVER_TOKENS: "off" VIRTUAL_HOST: web.nginx-proxy.tld
web-server-tokens-off:
image: web
expose:
- "80"
environment:
WEB_PORTS: 80
VIRTUAL_HOST: web-server-tokens-off.nginx-proxy.tld
SERVER_TOKENS: "off"
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
volumes: volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro
- ./certs/web.nginx-proxy.tld.crt:/etc/nginx/certs/default.crt:ro - ./certs/web.nginx-proxy.tld.crt:/etc/nginx/certs/default.crt:ro
- ./certs/web.nginx-proxy.tld.key:/etc/nginx/certs/default.key:ro - ./certs/web.nginx-proxy.tld.key:/etc/nginx/certs/default.key:ro
- ./certs/web.nginx-proxy.tld.crt:/etc/nginx/certs/web.nginx-proxy.tld.crt:ro - ./certs/web.nginx-proxy.tld.crt:/etc/nginx/certs/web.nginx-proxy.tld.crt:ro
- ./certs/web.nginx-proxy.tld.key:/etc/nginx/certs/web.nginx-proxy.tld.key:ro - ./certs/web.nginx-proxy.tld.key:/etc/nginx/certs/web.nginx-proxy.tld.key:ro
- ./certs/web-server-tokens-off.nginx-proxy.tld.crt:/etc/nginx/certs/web-server-tokens-off.nginx-proxy.tld.crt:ro - ./certs/web-server-tokens-off.nginx-proxy.tld.crt:/etc/nginx/certs/web-server-tokens-off.nginx-proxy.tld.crt:ro
- ./certs/web-server-tokens-off.nginx-proxy.tld.key:/etc/nginx/certs/web-server-tokens-off.nginx-proxy.tld.key:ro - ./certs/web-server-tokens-off.nginx-proxy.tld.key:/etc/nginx/certs/web-server-tokens-off.nginx-proxy.tld.key:ro

View File

@ -1,3 +1,5 @@
version: "2"
services: services:
http2-global-disabled: http2-global-disabled:
image: web image: web

View File

@ -1,3 +1,5 @@
version: "2"
services: services:
http3-global-disabled: http3-global-disabled:
image: web image: web
@ -12,4 +14,4 @@ services:
volumes: volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro
#environment: #environment:
#ENABLE_HTTP3: "false" #Disabled by default #ENABLE_HTTP3: "false" #Disabled by default

View File

@ -1,3 +1,5 @@
version: "2"
services: services:
http3-global-enabled: http3-global-enabled:
image: web image: web

View File

@ -1,3 +1,5 @@
version: "2"
services: services:
http3-vhost-enabled: http3-vhost-enabled:
image: web image: web

View File

@ -1,14 +1,17 @@
web1: version: "2"
image: web
expose:
- "81"
environment:
WEB_PORTS: "81"
VIRTUAL_HOST: "*.nginx-proxy.tld"
sut: services:
image: nginxproxy/nginx-proxy:test web1:
volumes: image: web
- /var/run/docker.sock:/tmp/docker.sock:ro expose:
environment: - "81"
HTTP_PORT: 8080 environment:
WEB_PORTS: "81"
VIRTUAL_HOST: "*.nginx-proxy.tld"
sut:
image: nginxproxy/nginx-proxy:test
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
environment:
HTTP_PORT: 8080

View File

@ -1,23 +1,25 @@
web1: version: "2"
image: web
expose:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: web1.nginx-proxy.example
NETWORK_ACCESS: internal
web2: services:
image: web web1:
expose: image: web
- "82" expose:
environment: - "81"
WEB_PORTS: 82 environment:
VIRTUAL_HOST: web2.nginx-proxy.example WEB_PORTS: 81
VIRTUAL_HOST: web1.nginx-proxy.example
NETWORK_ACCESS: internal
sut: web2:
image: nginxproxy/nginx-proxy:test image: web
volumes: expose:
- /var/run/docker.sock:/tmp/docker.sock:ro - "82"
- ./network_internal.conf:/etc/nginx/network_internal.conf:ro environment:
WEB_PORTS: 82
VIRTUAL_HOST: web2.nginx-proxy.example
sut:
image: nginxproxy/nginx-proxy:test
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./network_internal.conf:/etc/nginx/network_internal.conf:ro

View File

@ -1,27 +1,29 @@
web1: version: "2"
image: web
expose:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: nginx-proxy.example
VIRTUAL_PATH: /web1/
VIRTUAL_DEST: /
NETWORK_ACCESS: internal
web2: services:
image: web web1:
expose: image: web
- "82" expose:
environment: - "81"
WEB_PORTS: 82 environment:
VIRTUAL_HOST: nginx-proxy.example WEB_PORTS: 81
VIRTUAL_PATH: /web2/ VIRTUAL_HOST: nginx-proxy.example
VIRTUAL_DEST: / VIRTUAL_PATH: /web1/
VIRTUAL_DEST: /
NETWORK_ACCESS: internal
sut: web2:
image: nginxproxy/nginx-proxy:test image: web
volumes: expose:
- /var/run/docker.sock:/tmp/docker.sock:ro - "82"
- ./network_internal.conf:/etc/nginx/network_internal.conf:ro environment:
WEB_PORTS: 82
VIRTUAL_HOST: nginx-proxy.example
VIRTUAL_PATH: /web2/
VIRTUAL_DEST: /
sut:
image: nginxproxy/nginx-proxy:test
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./network_internal.conf:/etc/nginx/network_internal.conf:ro

View File

@ -1,4 +1,4 @@
version: '2' version: "2"
networks: networks:
net1: net1:
@ -28,7 +28,6 @@ services:
networks: networks:
- net1 - net1
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
volumes: volumes:

View File

@ -1,25 +1,27 @@
keepalive-disabled: version: "2"
image: web
expose:
- "80"
environment:
WEB_PORTS: 80
VIRTUAL_HOST: keepalive-disabled.nginx-proxy.test
keepalive-enabled: services:
image: web keepalive-disabled:
expose: image: web
- "80" expose:
environment: - "80"
WEB_PORTS: 80 environment:
VIRTUAL_HOST: keepalive-enabled.nginx-proxy.test WEB_PORTS: 80
labels: VIRTUAL_HOST: keepalive-disabled.nginx-proxy.test
com.github.nginx-proxy.nginx-proxy.keepalive: "64"
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: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
volumes: volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro
environment: environment:
HTTPS_METHOD: nohttps HTTPS_METHOD: nohttps

View File

@ -1,3 +1,5 @@
version: "2"
services: services:
loadbalance-hash: loadbalance-hash:
image: web image: web

View File

@ -1,3 +1,5 @@
version: "2"
services: services:
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test

View File

@ -1,15 +1,18 @@
web1: version: "2"
image: web
expose:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: nginx-proxy.test
sut: services:
container_name: sut web1:
image: nginxproxy/nginx-proxy:test image: web
volumes: expose:
- /var/run/docker.sock:/tmp/docker.sock:ro - "81"
environment: 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" WEB_PORTS: 81
VIRTUAL_HOST: nginx-proxy.test
sut:
container_name: sut
image: nginxproxy/nginx-proxy:test
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'

View File

@ -1,13 +1,15 @@
web: version: "2"
image: web
expose:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: webA.nginx-proxy.tld,webB.nginx-proxy.tld
services:
web:
image: web
expose:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: webA.nginx-proxy.tld,webB.nginx-proxy.tld
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
volumes: volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro

View File

@ -1,4 +1,4 @@
version: '2' version: "2"
networks: networks:
net1: {} net1: {}

View File

@ -1,14 +1,16 @@
web: version: "2"
image: web
expose:
- "81"
environment:
WEB_PORTS: "81"
VIRTUAL_HOST: "web.nginx-proxy.tld"
VIRTUAL_PORT: "90"
services:
web:
image: web
expose:
- "81"
environment:
WEB_PORTS: "81"
VIRTUAL_HOST: "web.nginx-proxy.tld"
VIRTUAL_PORT: "90"
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
volumes: volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro

View File

@ -1,14 +1,17 @@
web: version: "2"
image: web
expose:
- "80"
- "90"
environment:
WEB_PORTS: "80 90"
VIRTUAL_HOST: "web.nginx-proxy.tld"
VIRTUAL_PORT: 90
sut: services:
image: nginxproxy/nginx-proxy:test web:
volumes: image: web
- /var/run/docker.sock:/tmp/docker.sock:ro expose:
- "80"
- "90"
environment:
WEB_PORTS: "80 90"
VIRTUAL_HOST: "web.nginx-proxy.tld"
VIRTUAL_PORT: 90
sut:
image: nginxproxy/nginx-proxy:test
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro

View File

@ -1,13 +1,16 @@
web: version: "2"
image: web
expose:
- "80"
- "81"
environment:
WEB_PORTS: "80 81"
VIRTUAL_HOST: "web.nginx-proxy.tld"
sut: services:
image: nginxproxy/nginx-proxy:test web:
volumes: image: web
- /var/run/docker.sock:/tmp/docker.sock:ro expose:
- "80"
- "81"
environment:
WEB_PORTS: "80 81"
VIRTUAL_HOST: "web.nginx-proxy.tld"
sut:
image: nginxproxy/nginx-proxy:test
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro

View File

@ -1,13 +1,15 @@
web: version: "2"
image: web
expose:
- "81"
environment:
WEB_PORTS: "81"
VIRTUAL_HOST: "web.nginx-proxy.tld"
services:
web:
image: web
expose:
- "81"
environment:
WEB_PORTS: "81"
VIRTUAL_HOST: "web.nginx-proxy.tld"
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
volumes: volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro

View File

@ -1,4 +1,4 @@
version: '2' version: "2"
networks: networks:
net1: net1:
@ -28,7 +28,6 @@ services:
networks: networks:
- net1 - net1
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
volumes: volumes:

View File

@ -1,4 +1,4 @@
version: '2' version: "2"
networks: networks:
net1: net1:
@ -6,7 +6,7 @@ networks:
ipam: ipam:
config: config:
- subnet: 172.20.0.0/16 - subnet: 172.20.0.0/16
- subnet: fd00::/80 - subnet: fd00::/80
services: services:
web1: web1:

View File

@ -1,29 +1,32 @@
web1: version: "2"
image: web
expose:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: web.nginx-proxy.tld
web2: services:
image: web web1:
expose: image: web
- "82" expose:
environment: - "81"
WEB_PORTS: 83 environment:
VIRTUAL_HOST: web.nginx-proxy.tld WEB_PORTS: 81
VIRTUAL_HOST: web.nginx-proxy.tld
web3: web2:
image: web image: web
expose: expose:
- "83" - "82"
environment: environment:
WEB_PORTS: 83 WEB_PORTS: 83
VIRTUAL_HOST: web.nginx-proxy.tld VIRTUAL_HOST: web.nginx-proxy.tld
net: "none"
sut: web3:
image: nginxproxy/nginx-proxy:test image: web
volumes: expose:
- /var/run/docker.sock:/tmp/docker.sock:ro - "83"
environment:
WEB_PORTS: 83
VIRTUAL_HOST: web.nginx-proxy.tld
network_mode: "none"
sut:
image: nginxproxy/nginx-proxy:test
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro

View File

@ -1,12 +1,15 @@
web: version: "2"
image: web
expose:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: web.nginx-proxy.tld
sut: services:
image: nginxproxy/nginx-proxy:test web:
volumes: image: web
- /var/run/docker.sock:/tmp/docker.sock:ro expose:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: web.nginx-proxy.tld
sut:
image: nginxproxy/nginx-proxy:test
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro

View File

@ -1,13 +1,16 @@
web: version: "2"
image: web
expose:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: web.nginx-proxy.tld
net: "none"
sut: services:
image: nginxproxy/nginx-proxy:test web:
volumes: image: web
- /var/run/docker.sock:/tmp/docker.sock:ro expose:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: web.nginx-proxy.tld
network_mode: "none"
sut:
image: nginxproxy/nginx-proxy:test
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro

View File

@ -3,6 +3,7 @@ import subprocess
import backoff import backoff
import docker import docker
import pprint
import pytest import pytest
docker_client = docker.from_env() docker_client = docker.from_env()
@ -60,7 +61,8 @@ def require_openssl(required_version):
@require_openssl("1.0.2") @require_openssl("1.0.2")
def negotiate_cipher(sut_container, additional_params='', grep='Cipher is'): 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: try:
# Enforce TLS 1.2 as newer versions don't support custom dhparam or ciphersuite preference. # 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: except subprocess.CalledProcessError as e:
# Output a more helpful error, the original exception in this case isn't that helpful. # Output a more helpful error, the original exception in this case isn't that helpful.
# `from None` to ignore undesired output from exception chaining. # `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. # The default `dh_bits` can vary due to configuration.

View File

@ -1,73 +1,75 @@
web5: version: "2"
image: web
expose:
- "85"
environment:
WEB_PORTS: "85"
VIRTUAL_HOST: "web5.nginx-proxy.tld"
# Intended for testing with `dh-file` container. services:
# VIRTUAL_HOST is paired with site-specific DH param file. web5:
# DEFAULT_HOST is required to avoid defaulting to web2, image: web
# if not specifying FQDN (`-servername`) in openssl queries. expose:
web2: - "85"
image: web environment:
expose: WEB_PORTS: "85"
- "85" VIRTUAL_HOST: "web5.nginx-proxy.tld"
environment:
WEB_PORTS: "85"
VIRTUAL_HOST: "web2.nginx-proxy.tld"
# Intended for testing with `dh-file` container.
# VIRTUAL_HOST is paired with site-specific DH param file.
# DEFAULT_HOST is required to avoid defaulting to web2,
# if not specifying FQDN (`-servername`) in openssl queries.
web2:
image: web
expose:
- "85"
environment:
WEB_PORTS: "85"
VIRTUAL_HOST: "web2.nginx-proxy.tld"
# sut - System Under Test # sut - System Under Test
# `docker.sock` required for functionality # `docker.sock` required for functionality
# `certs` required to enable HTTPS via template # `certs` required to enable HTTPS via template
with_default_group: with_default_group:
container_name: dh-default container_name: dh-default
image: &img-nginxproxy nginxproxy/nginx-proxy:test image: &img-nginxproxy nginxproxy/nginx-proxy:test
environment: &env-common environment: &env-common
- &default-host DEFAULT_HOST=web5.nginx-proxy.tld - &default-host DEFAULT_HOST=web5.nginx-proxy.tld
volumes: &vols-common volumes: &vols-common
- &docker-sock /var/run/docker.sock:/tmp/docker.sock:ro - &docker-sock /var/run/docker.sock:/tmp/docker.sock:ro
- &nginx-certs ./certs:/etc/nginx/certs:ro - &nginx-certs ./certs:/etc/nginx/certs:ro
with_alternative_group: with_alternative_group:
container_name: dh-env container_name: dh-env
environment: environment:
- DHPARAM_BITS=3072 - DHPARAM_BITS=3072
- *default-host - *default-host
image: *img-nginxproxy image: *img-nginxproxy
volumes: *vols-common volumes: *vols-common
with_invalid_group: with_invalid_group:
container_name: invalid-group-1024 container_name: invalid-group-1024
environment: environment:
- DHPARAM_BITS=1024 - DHPARAM_BITS=1024
- *default-host - *default-host
image: *img-nginxproxy image: *img-nginxproxy
volumes: *vols-common volumes: *vols-common
with_custom_file: with_custom_file:
container_name: dh-file container_name: dh-file
image: *img-nginxproxy image: *img-nginxproxy
environment: *env-common environment: *env-common
volumes: volumes:
- *docker-sock - *docker-sock
- *nginx-certs - *nginx-certs
- ../../app/dhparam/ffdhe3072.pem:/etc/nginx/dhparam/dhparam.pem:ro - ../../app/dhparam/ffdhe3072.pem:/etc/nginx/dhparam/dhparam.pem:ro
with_skip: with_skip:
container_name: dh-skip container_name: dh-skip
environment: environment:
- DHPARAM_SKIP=true - DHPARAM_SKIP=true
- *default-host - *default-host
image: *img-nginxproxy image: *img-nginxproxy
volumes: *vols-common volumes: *vols-common
with_skip_backward: with_skip_backward:
container_name: dh-skip-backward container_name: dh-skip-backward
environment: environment:
- DHPARAM_GENERATION=false - DHPARAM_GENERATION=false
- *default-host - *default-host
image: *img-nginxproxy image: *img-nginxproxy
volumes: *vols-common volumes: *vols-common

View File

@ -1,51 +1,54 @@
web1: version: "2"
image: web
expose:
- "81"
environment:
WEB_PORTS: "81"
VIRTUAL_HOST: "web1.nginx-proxy.tld"
web2: services:
image: web web1:
expose: image: web
- "81" expose:
environment: - "81"
WEB_PORTS: "81" environment:
VIRTUAL_HOST: "web2.nginx-proxy.tld" WEB_PORTS: "81"
HSTS: "off" VIRTUAL_HOST: "web1.nginx-proxy.tld"
web3: web2:
image: web image: web
expose: expose:
- "81" - "81"
environment: environment:
WEB_PORTS: "81" WEB_PORTS: "81"
VIRTUAL_HOST: "web3.nginx-proxy.tld" VIRTUAL_HOST: "web2.nginx-proxy.tld"
HSTS: "max-age=86400; includeSubDomains; preload" HSTS: "off"
web4: web3:
image: web image: web
expose: expose:
- "81" - "81"
environment: environment:
WEB_PORTS: "81" WEB_PORTS: "81"
VIRTUAL_HOST: "web4.nginx-proxy.tld" VIRTUAL_HOST: "web3.nginx-proxy.tld"
HSTS: "off" HSTS: "max-age=86400; includeSubDomains; preload"
HTTPS_METHOD: "noredirect"
web5: web4:
image: web image: web
expose: expose:
- "81" - "81"
environment: environment:
WEB_PORTS: "81" WEB_PORTS: "81"
VIRTUAL_HOST: http3-vhost-enabled.nginx-proxy.tld VIRTUAL_HOST: "web4.nginx-proxy.tld"
labels: HSTS: "off"
com.github.nginx-proxy.nginx-proxy.http3.enable: "true" HTTPS_METHOD: "noredirect"
sut: web5:
image: nginxproxy/nginx-proxy:test image: web
volumes: expose:
- /var/run/docker.sock:/tmp/docker.sock:ro - "81"
- ./certs:/etc/nginx/certs:ro environment:
WEB_PORTS: "81"
VIRTUAL_HOST: http3-vhost-enabled.nginx-proxy.tld
labels:
com.github.nginx-proxy.nginx-proxy.http3.enable: "true"
sut:
image: nginxproxy/nginx-proxy:test
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./certs:/etc/nginx/certs:ro

View File

@ -1,16 +1,19 @@
web1: version: "2"
image: web
expose:
- "81"
environment:
WEB_PORTS: "81"
VIRTUAL_HOST: "*.nginx-proxy.tld"
sut: services:
image: nginxproxy/nginx-proxy:test web1:
volumes: image: web
- /var/run/docker.sock:/tmp/docker.sock:ro expose:
- ./certs:/etc/nginx/certs:ro - "81"
environment: environment:
HTTP_PORT: 8080 WEB_PORTS: "81"
HTTPS_PORT: 8443 VIRTUAL_HOST: "*.nginx-proxy.tld"
sut:
image: nginxproxy/nginx-proxy:test
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./certs:/etc/nginx/certs:ro
environment:
HTTP_PORT: 8080
HTTPS_PORT: 8443

View File

@ -1,15 +1,17 @@
web2: version: "2"
image: web
expose:
- "82"
environment:
WEB_PORTS: "82"
VIRTUAL_HOST: "web2.nginx-proxy.tld"
HTTPS_METHOD: nohttp
services:
web2:
image: web
expose:
- "82"
environment:
WEB_PORTS: "82"
VIRTUAL_HOST: "web2.nginx-proxy.tld"
HTTPS_METHOD: nohttp
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
volumes: volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro
- ./certs:/etc/nginx/certs:ro - ./certs:/etc/nginx/certs:ro

View File

@ -1,14 +1,16 @@
web: version: "2"
image: web
expose:
- "83"
environment:
WEB_PORTS: "83"
VIRTUAL_HOST: "web.nginx-proxy.tld"
HTTPS_METHOD: nohttps
services:
web:
image: web
expose:
- "83"
environment:
WEB_PORTS: "83"
VIRTUAL_HOST: "web.nginx-proxy.tld"
HTTPS_METHOD: nohttps
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
volumes: volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro

View File

@ -1,15 +1,17 @@
web3: version: "2"
image: web
expose:
- "83"
environment:
WEB_PORTS: "83"
VIRTUAL_HOST: "web3.nginx-proxy.tld"
HTTPS_METHOD: noredirect
services:
web3:
image: web
expose:
- "83"
environment:
WEB_PORTS: "83"
VIRTUAL_HOST: "web3.nginx-proxy.tld"
HTTPS_METHOD: noredirect
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
volumes: volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro
- ./certs:/etc/nginx/certs:ro - ./certs:/etc/nginx/certs:ro

View File

@ -1,26 +1,28 @@
web1: version: "2"
image: web
expose:
- "81"
environment:
WEB_PORTS: "81"
VIRTUAL_HOST: "www.nginx-proxy.tld"
VIRTUAL_PATH: "/web1/"
VIRTUAL_DEST: "/"
web2: services:
image: web web1:
expose: image: web
- "82" expose:
environment: - "81"
WEB_PORTS: "82" environment:
VIRTUAL_HOST: "www.nginx-proxy.tld" WEB_PORTS: "81"
VIRTUAL_PATH: "/web2/" VIRTUAL_HOST: "www.nginx-proxy.tld"
VIRTUAL_DEST: "/" VIRTUAL_PATH: "/web1/"
VIRTUAL_DEST: "/"
sut: web2:
image: nginxproxy/nginx-proxy:test image: web
volumes: expose:
- /var/run/docker.sock:/tmp/docker.sock:ro - "82"
- ./certs:/etc/nginx/certs:ro environment:
WEB_PORTS: "82"
VIRTUAL_HOST: "www.nginx-proxy.tld"
VIRTUAL_PATH: "/web2/"
VIRTUAL_DEST: "/"
sut:
image: nginxproxy/nginx-proxy:test
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./certs:/etc/nginx/certs:ro

View File

@ -1,13 +1,16 @@
web1: version: "2"
image: web
expose:
- "81"
environment:
WEB_PORTS: "81"
VIRTUAL_HOST: "*.nginx-proxy.tld"
sut: services:
image: nginxproxy/nginx-proxy:test web1:
volumes: image: web
- /var/run/docker.sock:/tmp/docker.sock:ro expose:
- ./certs:/etc/nginx/certs:ro - "81"
environment:
WEB_PORTS: "81"
VIRTUAL_HOST: "*.nginx-proxy.tld"
sut:
image: nginxproxy/nginx-proxy:test
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./certs:/etc/nginx/certs:ro

View File

@ -1,16 +1,18 @@
web: version: "2"
image: web
expose:
- "80"
environment:
WEB_PORTS: 80
VIRTUAL_HOST: web.nginx-proxy.tld
HTTPS_METHOD: noredirect
services:
web:
image: web
expose:
- "80"
environment:
WEB_PORTS: 80
VIRTUAL_HOST: web.nginx-proxy.tld
HTTPS_METHOD: noredirect
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
volumes: volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro
- ./certs/web.nginx-proxy.tld.crt:/etc/nginx/certs/web.nginx-proxy.tld.crt:ro - ./certs/web.nginx-proxy.tld.crt:/etc/nginx/certs/web.nginx-proxy.tld.crt:ro
- ./certs/web.nginx-proxy.tld.key:/etc/nginx/certs/web.nginx-proxy.tld.key:ro - ./certs/web.nginx-proxy.tld.key:/etc/nginx/certs/web.nginx-proxy.tld.key:ro

View File

@ -1,18 +1,20 @@
web: version: "2"
image: web
expose:
- "80"
environment:
WEB_PORTS: 80
VIRTUAL_HOST: web.nginx-proxy.tld
HTTPS_METHOD: noredirect
services:
web:
image: web
expose:
- "80"
environment:
WEB_PORTS: 80
VIRTUAL_HOST: web.nginx-proxy.tld
HTTPS_METHOD: noredirect
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
environment: environment:
TRUST_DOWNSTREAM_PROXY: "false" TRUST_DOWNSTREAM_PROXY: "false"
volumes: volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro
- ./certs/web.nginx-proxy.tld.crt:/etc/nginx/certs/web.nginx-proxy.tld.crt:ro - ./certs/web.nginx-proxy.tld.crt:/etc/nginx/certs/web.nginx-proxy.tld.crt:ro
- ./certs/web.nginx-proxy.tld.key:/etc/nginx/certs/web.nginx-proxy.tld.key:ro - ./certs/web.nginx-proxy.tld.key:/etc/nginx/certs/web.nginx-proxy.tld.key:ro

View File

@ -1,18 +1,20 @@
web: version: "2"
image: web
expose:
- "80"
environment:
WEB_PORTS: 80
VIRTUAL_HOST: web.nginx-proxy.tld
HTTPS_METHOD: noredirect
services:
web:
image: web
expose:
- "80"
environment:
WEB_PORTS: 80
VIRTUAL_HOST: web.nginx-proxy.tld
HTTPS_METHOD: noredirect
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
environment: environment:
TRUST_DOWNSTREAM_PROXY: "true" TRUST_DOWNSTREAM_PROXY: "true"
volumes: volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro
- ./certs/web.nginx-proxy.tld.crt:/etc/nginx/certs/web.nginx-proxy.tld.crt:ro - ./certs/web.nginx-proxy.tld.crt:/etc/nginx/certs/web.nginx-proxy.tld.crt:ro
- ./certs/web.nginx-proxy.tld.key:/etc/nginx/certs/web.nginx-proxy.tld.key:ro - ./certs/web.nginx-proxy.tld.key:/etc/nginx/certs/web.nginx-proxy.tld.key:ro

View File

@ -1,4 +1,4 @@
version: '2' version: "2"
services: services:
web: web:

View File

@ -1,4 +1,4 @@
version: '2' version: "2"
services: services:
web: web:

View File

@ -1,8 +1,11 @@
version: "2"
services: services:
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
volumes: volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro
web1: web1:
image: web image: web
expose: expose:
@ -11,6 +14,7 @@ services:
WEB_PORTS: "81" WEB_PORTS: "81"
# The space is intentional (should be trimmed). # The space is intentional (should be trimmed).
VIRTUAL_HOST: " " VIRTUAL_HOST: " "
web2: web2:
image: web image: web
expose: expose:
@ -19,6 +23,7 @@ services:
WEB_PORTS: "82" WEB_PORTS: "82"
# The space is intentional (should be trimmed). # The space is intentional (should be trimmed).
VIRTUAL_HOST: "web2.nginx-proxy.test ," VIRTUAL_HOST: "web2.nginx-proxy.test ,"
web3: web3:
image: web image: web
expose: expose:
@ -27,6 +32,7 @@ services:
WEB_PORTS: "83" WEB_PORTS: "83"
# The space is intentional (should be trimmed). # The space is intentional (should be trimmed).
VIRTUAL_HOST: " ,web3.nginx-proxy.test" VIRTUAL_HOST: " ,web3.nginx-proxy.test"
web4: web4:
image: web image: web
expose: expose:

View File

@ -1,4 +1,4 @@
version: '2' version: "2"
networks: networks:
net1: {} net1: {}

View File

@ -1,48 +1,49 @@
version: "2"
foo: services:
image: web foo:
expose: image: web
- "42" expose:
environment: - "42"
WEB_PORTS: "42" environment:
VIRTUAL_HOST: "foo.nginx-proxy.test" WEB_PORTS: "42"
VIRTUAL_HOST: "foo.nginx-proxy.test"
web1: web1:
image: web image: web
expose: expose:
- "81" - "81"
environment: environment:
WEB_PORTS: "81" WEB_PORTS: "81"
VIRTUAL_HOST: "nginx-proxy.test" VIRTUAL_HOST: "nginx-proxy.test"
VIRTUAL_PATH: "/web1/" VIRTUAL_PATH: "/web1/"
VIRTUAL_DEST: "/" VIRTUAL_DEST: "/"
web2: web2:
image: web image: web
expose: expose:
- "82" - "82"
environment: environment:
WEB_PORTS: "82" WEB_PORTS: "82"
VIRTUAL_HOST: "nginx-proxy.test" VIRTUAL_HOST: "nginx-proxy.test"
VIRTUAL_PATH: "/web2/" VIRTUAL_PATH: "/web2/"
VIRTUAL_DEST: "/" VIRTUAL_DEST: "/"
web3: web3:
image: web image: web
expose: expose:
- "83" - "83"
environment: environment:
WEB_PORTS: "83" WEB_PORTS: "83"
VIRTUAL_HOST: "nginx-proxy.test" VIRTUAL_HOST: "nginx-proxy.test"
VIRTUAL_PATH: "~ ^/(web3|alt)/" VIRTUAL_PATH: "~ ^/(web3|alt)/"
sut:
image: nginxproxy/nginx-proxy:test
environment:
DEFAULT_ROOT: 418
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./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
sut:
image: nginxproxy/nginx-proxy:test
environment:
DEFAULT_ROOT: 418
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./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

View File

@ -1,17 +1,20 @@
web1: version: "2"
image: web
expose:
- "81"
environment:
WEB_PORTS: "81"
VIRTUAL_HOST: "www.nginx-proxy.tld"
VIRTUAL_PATH: "/web1/"
VIRTUAL_DEST: "/"
sut: services:
image: nginxproxy/nginx-proxy:test web1:
volumes: image: web
- /var/run/docker.sock:/tmp/docker.sock:ro expose:
- ./certs:/etc/nginx/certs:ro - "81"
environment: environment:
- DEFAULT_ROOT=301 http://$$host/web1$$request_uri 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
- ./certs:/etc/nginx/certs:ro
environment:
- DEFAULT_ROOT=301 http://$$host/web1$$request_uri

View File

@ -1,37 +1,40 @@
web1: version: "2"
image: web
expose:
- "81"
environment:
WEB_PORTS: "81"
VIRTUAL_HOST: "foo.nginx-proxy.test"
VIRTUAL_PATH: "/web1/"
VIRTUAL_DEST: "/"
web2: services:
image: web web1:
expose: image: web
- "82" expose:
environment: - "81"
WEB_PORTS: "82" environment:
VIRTUAL_HOST: "bar.nginx-proxy.test" WEB_PORTS: "81"
VIRTUAL_PATH: "/web2/" VIRTUAL_HOST: "foo.nginx-proxy.test"
VIRTUAL_DEST: "/" VIRTUAL_PATH: "/web1/"
VIRTUAL_DEST: "/"
web3: web2:
image: web image: web
expose: expose:
- "83" - "82"
environment: environment:
WEB_PORTS: "83" WEB_PORTS: "82"
VIRTUAL_HOST: "bar.nginx-proxy.test" VIRTUAL_HOST: "bar.nginx-proxy.test"
VIRTUAL_PATH: "/web3/" VIRTUAL_PATH: "/web2/"
VIRTUAL_DEST: "/" VIRTUAL_DEST: "/"
sut: web3:
image: nginxproxy/nginx-proxy:test image: web
volumes: expose:
- /var/run/docker.sock:/tmp/docker.sock:ro - "83"
- ./default.conf:/etc/nginx/vhost.d/default_location:ro environment:
- ./host.conf:/etc/nginx/vhost.d/bar.nginx-proxy.test_location:ro WEB_PORTS: "83"
- ./path.conf:/etc/nginx/vhost.d/bar.nginx-proxy.test_99f2db0ed8aa95dbb5b87fca79c7eff2ff6bb8bd_location:ro VIRTUAL_HOST: "bar.nginx-proxy.test"
VIRTUAL_PATH: "/web3/"
VIRTUAL_DEST: "/"
sut:
image: nginxproxy/nginx-proxy:test
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./default.conf:/etc/nginx/vhost.d/default_location:ro
- ./host.conf:/etc/nginx/vhost.d/bar.nginx-proxy.test_location:ro
- ./path.conf:/etc/nginx/vhost.d/bar.nginx-proxy.test_99f2db0ed8aa95dbb5b87fca79c7eff2ff6bb8bd_location:ro

View File

@ -39,6 +39,7 @@ def web4(docker_compose):
}, },
ports={"84/tcp": None} 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 sleep(2) # give it some time to initialize and for docker-gen to detect it
yield container yield container
try: try:

View File

@ -1,42 +1,44 @@
version: "2"
foo: services:
image: web foo:
expose: image: web
- "42" expose:
environment: - "42"
WEB_PORTS: "42" environment:
VIRTUAL_HOST: "foo.nginx-proxy.test" WEB_PORTS: "42"
VIRTUAL_HOST: "foo.nginx-proxy.test"
web1: web1:
image: web image: web
expose: expose:
- "81" - "81"
environment: environment:
WEB_PORTS: "81" WEB_PORTS: "81"
VIRTUAL_HOST: "nginx-proxy.test" VIRTUAL_HOST: "nginx-proxy.test"
VIRTUAL_PATH: "/web1/" VIRTUAL_PATH: "/web1/"
VIRTUAL_DEST: "/" VIRTUAL_DEST: "/"
web2: web2:
image: web image: web
expose: expose:
- "82" - "82"
environment: environment:
WEB_PORTS: "82" WEB_PORTS: "82"
VIRTUAL_HOST: "nginx-proxy.test" VIRTUAL_HOST: "nginx-proxy.test"
VIRTUAL_PATH: "/web2/" VIRTUAL_PATH: "/web2/"
VIRTUAL_DEST: "/" VIRTUAL_DEST: "/"
web3: web3:
image: web image: web
expose: expose:
- "83" - "83"
environment: environment:
WEB_PORTS: "83" WEB_PORTS: "83"
VIRTUAL_HOST: "nginx-proxy.test" VIRTUAL_HOST: "nginx-proxy.test"
VIRTUAL_PATH: "/" VIRTUAL_PATH: "/"
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
volumes: volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro

View File

@ -1,37 +1,39 @@
web1: version: "2"
image: web
expose:
- "81"
environment:
WEB_PORTS: "81"
VIRTUAL_HOST: "*.nginx-proxy.test"
web2: services:
image: web web1:
expose: image: web
- "82" expose:
environment: - "81"
WEB_PORTS: "82" environment:
VIRTUAL_HOST: "test.nginx-proxy.*" WEB_PORTS: "81"
VIRTUAL_HOST: "*.nginx-proxy.test"
web3: web2:
image: web image: web
expose: expose:
- "83" - "82"
environment: environment:
WEB_PORTS: "83" WEB_PORTS: "82"
VIRTUAL_HOST: ~^web3\..*\.nginx-proxy\.regexp VIRTUAL_HOST: "test.nginx-proxy.*"
web4: web3:
image: web image: web
expose: expose:
- "84" - "83"
environment: environment:
WEB_PORTS: "84" WEB_PORTS: "83"
VIRTUAL_HOST: ~^web4\..*\.nginx-proxy\.regexp$$ # we need to double the `$` because of docker-compose variable interpolation VIRTUAL_HOST: ~^web3\..*\.nginx-proxy\.regexp
web4:
image: web
expose:
- "84"
environment:
WEB_PORTS: "84"
VIRTUAL_HOST: ~^web4\..*\.nginx-proxy\.regexp$$ # we need to double the `$` because of docker compose variable interpolation
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test
volumes: volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro