-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Use container names for upstream names to avoid repeats
- Loading branch information
Showing
5 changed files
with
225 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import pytest | ||
import re | ||
|
||
|
||
def test_single_container_in_upstream(docker_compose, nginxproxy): | ||
conf = nginxproxy.get_conf().decode() | ||
assert re.search(r"upstream web1~ \{", conf) | ||
|
||
def test_multiple_containers_in_upstream(docker_compose, nginxproxy): | ||
conf = nginxproxy.get_conf().decode() | ||
assert re.search(r"upstream web2~web3~ \{", conf) | ||
|
||
def test_no_redundant_upstreams(docker_compose, nginxproxy): | ||
conf = nginxproxy.get_conf().decode() | ||
assert len(re.findall(r"upstream web4~ \{", conf)) == 1 | ||
|
||
def test_valid_upstream_name(docker_compose, nginxproxy): | ||
"""nginx should not choke on the tilde character.""" | ||
r = nginxproxy.get("http://web1.nginx-proxy.test/port") | ||
assert r.status_code == 200 | ||
assert r.text == "answer from port 80\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
version: '2' | ||
|
||
services: | ||
web1: | ||
container_name: web1 | ||
image: web | ||
expose: | ||
- "80" | ||
environment: | ||
WEB_PORTS: 80 | ||
VIRTUAL_HOST: web1.nginx-proxy.test | ||
web2: | ||
container_name: web2 | ||
image: web | ||
expose: | ||
- "80" | ||
environment: | ||
WEB_PORTS: 80 | ||
VIRTUAL_HOST: web23.nginx-proxy.test | ||
web3: | ||
container_name: web3 | ||
image: web | ||
expose: | ||
- "80" | ||
environment: | ||
WEB_PORTS: 80 | ||
VIRTUAL_HOST: web23.nginx-proxy.test | ||
web4: | ||
container_name: web4 | ||
image: web | ||
expose: | ||
- "80" | ||
environment: | ||
WEB_PORTS: 80 | ||
VIRTUAL_HOST: web4a.nginx-proxy.test,web4b.nginx-proxy.test | ||
|
||
sut: | ||
image: nginxproxy/nginx-proxy:test | ||
volumes: | ||
- /var/run/docker.sock:/tmp/docker.sock:ro | ||
environment: | ||
UPSTREAM_NAME_STYLE: container-name |