mirror of
https://github.com/thib8956/nginx-proxy
synced 2025-02-24 09:48:14 +00:00
Merge pull request #1985 from hiqdev/networks-order
Make sure networks order is the same
This commit is contained in:
commit
7c0d38cd2e
@ -105,7 +105,7 @@ upstream {{ .Upstream }} {
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ range $knownNetwork := $networks }}
|
{{ range $knownNetwork := $networks }}
|
||||||
{{ range $containerNetwork := $container.Networks }}
|
{{ range $containerNetwork := sortObjectsByKeysAsc $container.Networks "Name" }}
|
||||||
{{ if (and (ne $containerNetwork.Name "ingress") (or (eq $knownNetwork.Name $containerNetwork.Name) (eq $knownNetwork.Name "host"))) }}
|
{{ if (and (ne $containerNetwork.Name "ingress") (or (eq $knownNetwork.Name $containerNetwork.Name) (eq $knownNetwork.Name "host"))) }}
|
||||||
## Can be connected with "{{ $containerNetwork.Name }}" network
|
## Can be connected with "{{ $containerNetwork.Name }}" network
|
||||||
{{ if $address }}
|
{{ if $address }}
|
||||||
|
29
test/test_vhost-in-multiple-networks.py
Normal file
29
test/test_vhost-in-multiple-networks.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import pytest
|
||||||
|
import logging
|
||||||
|
import time
|
||||||
|
|
||||||
|
def test_forwards_to_web1(docker_compose, nginxproxy):
|
||||||
|
r = nginxproxy.get("http://web1.nginx-proxy.local/port")
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert r.text == "answer from port 81\n"
|
||||||
|
|
||||||
|
def test_nginx_config_remains_the_same_after_restart(docker_compose, nginxproxy):
|
||||||
|
"""
|
||||||
|
Restarts the Web container and returns nginx-proxy config after restart
|
||||||
|
"""
|
||||||
|
def get_conf_after_web_container_restart():
|
||||||
|
web_containers = docker_compose.containers.list(filters={"ancestor": "web:latest"})
|
||||||
|
assert len(web_containers) == 1
|
||||||
|
web_containers[0].restart()
|
||||||
|
time.sleep(3)
|
||||||
|
|
||||||
|
return nginxproxy.get_conf()
|
||||||
|
|
||||||
|
config_before_restart = nginxproxy.get_conf()
|
||||||
|
|
||||||
|
for i in range(1, 8):
|
||||||
|
logging.info(f"Checking for the {i}-st time that config is the same")
|
||||||
|
config_after_restart = get_conf_after_web_container_restart()
|
||||||
|
if config_before_restart != config_after_restart:
|
||||||
|
logging.debug(f"{config_before_restart!r} \n\n {config_after_restart!r}")
|
||||||
|
pytest.fail("nginx-proxy config before and after restart of a web container does not match", pytrace=False)
|
26
test/test_vhost-in-multiple-networks.yml
Normal file
26
test/test_vhost-in-multiple-networks.yml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
version: '2'
|
||||||
|
|
||||||
|
networks:
|
||||||
|
net1: {}
|
||||||
|
net2: {}
|
||||||
|
net3: {}
|
||||||
|
|
||||||
|
services:
|
||||||
|
nginx-proxy:
|
||||||
|
image: nginxproxy/nginx-proxy:test
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||||
|
networks:
|
||||||
|
- net1
|
||||||
|
|
||||||
|
web:
|
||||||
|
image: web
|
||||||
|
expose:
|
||||||
|
- "81"
|
||||||
|
environment:
|
||||||
|
WEB_PORTS: 81
|
||||||
|
VIRTUAL_HOST: web1.nginx-proxy.local
|
||||||
|
networks:
|
||||||
|
- net1
|
||||||
|
- net2
|
||||||
|
- net3
|
Loading…
x
Reference in New Issue
Block a user