Skip to content

Commit

Permalink
Merge pull request #2250 from SaturnIC-Forks/main
Browse files Browse the repository at this point in the history
fix: Replace mDNS .local domain with .internal domain
  • Loading branch information
buchdag committed May 30, 2023
2 parents edb5875 + 13eb61a commit b382d0b
Show file tree
Hide file tree
Showing 24 changed files with 49 additions and 49 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ services:
expose:
- "8000"
environment:
- VIRTUAL_HOST=whoami.local
- VIRTUAL_HOST=whoami.example
- VIRTUAL_PORT=8000
```

```console
docker-compose up
curl -H "Host: whoami.local" localhost
curl -H "Host: whoami.example" localhost
```

Example output:
Expand Down Expand Up @@ -257,7 +257,7 @@ You can demo this pattern with docker-compose:

```console
docker-compose --file docker-compose-separate-containers.yml up
curl -H "Host: whoami.local" localhost
curl -H "Host: whoami.example" localhost
```

Example output:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-separate-containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ services:
whoami:
image: jwilder/whoami
environment:
- VIRTUAL_HOST=whoami.local
- VIRTUAL_HOST=whoami.example
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ services:
whoami:
image: jwilder/whoami
environment:
- VIRTUAL_HOST=whoami.local
- VIRTUAL_HOST=whoami.example
4 changes: 2 additions & 2 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ def ipv6(force_ipv6=True):
Meant to be used as a context manager to force IPv6 sockets:
with ipv6():
nginxproxy.get("http://something.nginx-proxy.local") # force use of IPv6
nginxproxy.get("http://something.nginx-proxy.example") # force use of IPv6
with ipv6(False):
nginxproxy.get("http://something.nginx-proxy.local") # legacy behavior
nginxproxy.get("http://something.nginx-proxy.example") # legacy behavior
"""
Expand Down
2 changes: 1 addition & 1 deletion test/test_composev2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ def test_unknown_virtual_host(docker_compose, nginxproxy):
assert r.status_code == 503

def test_forwards_to_whoami(docker_compose, nginxproxy):
r = nginxproxy.get("http://web.nginx-proxy.local/port")
r = nginxproxy.get("http://web.nginx-proxy.example/port")
assert r.status_code == 200
assert r.text == "answer from port 81\n"
2 changes: 1 addition & 1 deletion test/test_composev2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ services:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: web.nginx-proxy.local
VIRTUAL_HOST: web.nginx-proxy.example
6 changes: 3 additions & 3 deletions test/test_custom/test_defaults-location.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ def test_custom_default_conf_does_not_apply_to_unknown_vhost(docker_compose, ngi
assert "X-test" not in r.headers

def test_custom_default_conf_applies_to_web1(docker_compose, nginxproxy):
r = nginxproxy.get("http://web1.nginx-proxy.local/port")
r = nginxproxy.get("http://web1.nginx-proxy.example/port")
assert r.status_code == 200
assert r.text == "answer from port 81\n"
assert "X-test" in r.headers
assert "f00" == r.headers["X-test"]

def test_custom_default_conf_applies_to_web2(docker_compose, nginxproxy):
r = nginxproxy.get("http://web2.nginx-proxy.local/port")
r = nginxproxy.get("http://web2.nginx-proxy.example/port")
assert r.status_code == 200
assert r.text == "answer from port 82\n"
assert "X-test" in r.headers
assert "f00" == r.headers["X-test"]


def test_custom_default_conf_is_overriden_for_web3(docker_compose, nginxproxy):
r = nginxproxy.get("http://web3.nginx-proxy.local/port")
r = nginxproxy.get("http://web3.nginx-proxy.example/port")
assert r.status_code == 200
assert r.text == "answer from port 83\n"
assert "X-test" in r.headers
Expand Down
8 changes: 4 additions & 4 deletions test/test_custom/test_defaults-location.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@ nginx-proxy:
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.local_location:ro
- ./my_custom_proxy_settings_bar.conf:/etc/nginx/vhost.d/web3.nginx-proxy.example_location:ro

web1:
image: web
expose:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: web1.nginx-proxy.local
VIRTUAL_HOST: web1.nginx-proxy.example

web2:
image: web
expose:
- "82"
environment:
WEB_PORTS: 82
VIRTUAL_HOST: web2.nginx-proxy.local
VIRTUAL_HOST: web2.nginx-proxy.example

web3:
image: web
expose:
- "83"
environment:
WEB_PORTS: 83
VIRTUAL_HOST: web3.nginx-proxy.local
VIRTUAL_HOST: web3.nginx-proxy.example
4 changes: 2 additions & 2 deletions test/test_custom/test_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ def test_custom_conf_does_not_apply_to_unknown_vhost(docker_compose, nginxproxy)
assert "X-test" not in r.headers

def test_custom_conf_applies_to_web1(docker_compose, nginxproxy):
r = nginxproxy.get("http://web1.nginx-proxy.local/port")
r = nginxproxy.get("http://web1.nginx-proxy.example/port")
assert r.status_code == 200
assert r.text == "answer from port 81\n"
assert "X-test" in r.headers
assert "f00" == r.headers["X-test"]

def test_custom_conf_applies_to_web2(docker_compose, nginxproxy):
r = nginxproxy.get("http://web2.nginx-proxy.local/port")
r = nginxproxy.get("http://web2.nginx-proxy.example/port")
assert r.status_code == 200
assert r.text == "answer from port 82\n"
assert "X-test" in r.headers
Expand Down
4 changes: 2 additions & 2 deletions test/test_custom/test_defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ services:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: web1.nginx-proxy.local
VIRTUAL_HOST: web1.nginx-proxy.example

web2:
image: web
expose:
- "82"
environment:
WEB_PORTS: 82
VIRTUAL_HOST: web2.nginx-proxy.local
VIRTUAL_HOST: web2.nginx-proxy.example
6 changes: 3 additions & 3 deletions test/test_custom/test_location-per-vhost.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ def test_custom_conf_does_not_apply_to_unknown_vhost(docker_compose, nginxproxy)
assert "X-test" not in r.headers

def test_custom_conf_applies_to_web1(docker_compose, nginxproxy):
r = nginxproxy.get("http://web1.nginx-proxy.local/port")
r = nginxproxy.get("http://web1.nginx-proxy.example/port")
assert r.status_code == 200
assert r.text == "answer from port 81\n"
assert "X-test" in r.headers
assert "f00" == r.headers["X-test"]

def test_custom_conf_does_not_apply_to_web2(docker_compose, nginxproxy):
r = nginxproxy.get("http://web2.nginx-proxy.local/port")
r = nginxproxy.get("http://web2.nginx-proxy.example/port")
assert r.status_code == 200
assert r.text == "answer from port 82\n"
assert "X-test" not in r.headers

def test_custom_block_is_present_in_nginx_generated_conf(docker_compose, nginxproxy):
assert b"include /etc/nginx/vhost.d/web1.nginx-proxy.local_location;" in nginxproxy.get_conf()
assert b"include /etc/nginx/vhost.d/web1.nginx-proxy.example_location;" in nginxproxy.get_conf()
6 changes: 3 additions & 3 deletions test/test_custom/test_location-per-vhost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ services:
image: nginxproxy/nginx-proxy:test
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./my_custom_proxy_settings.conf:/etc/nginx/vhost.d/web1.nginx-proxy.local_location:ro
- ./my_custom_proxy_settings.conf:/etc/nginx/vhost.d/web1.nginx-proxy.example_location:ro

web1:
image: web
expose:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: web1.nginx-proxy.local
VIRTUAL_HOST: web1.nginx-proxy.example

web2:
image: web
expose:
- "82"
environment:
WEB_PORTS: 82
VIRTUAL_HOST: web2.nginx-proxy.local
VIRTUAL_HOST: web2.nginx-proxy.example
4 changes: 2 additions & 2 deletions test/test_custom/test_per-vhost.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ def test_custom_conf_does_not_apply_to_unknown_vhost(docker_compose, nginxproxy)
assert "X-test" not in r.headers

def test_custom_conf_applies_to_web1(docker_compose, nginxproxy):
r = nginxproxy.get("http://web1.nginx-proxy.local/port")
r = nginxproxy.get("http://web1.nginx-proxy.example/port")
assert r.status_code == 200
assert r.text == "answer from port 81\n"
assert "X-test" in r.headers
assert "f00" == r.headers["X-test"]

def test_custom_conf_does_not_apply_to_web2(docker_compose, nginxproxy):
r = nginxproxy.get("http://web2.nginx-proxy.local/port")
r = nginxproxy.get("http://web2.nginx-proxy.example/port")
assert r.status_code == 200
assert r.text == "answer from port 82\n"
assert "X-test" not in r.headers
6 changes: 3 additions & 3 deletions test/test_custom/test_per-vhost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ services:
image: nginxproxy/nginx-proxy:test
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./my_custom_proxy_settings.conf:/etc/nginx/vhost.d/web1.nginx-proxy.local:ro
- ./my_custom_proxy_settings.conf:/etc/nginx/vhost.d/web1.nginx-proxy.example:ro

web1:
image: web
expose:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: web1.nginx-proxy.local
VIRTUAL_HOST: web1.nginx-proxy.example

web2:
image: web
expose:
- "82"
environment:
WEB_PORTS: 82
VIRTUAL_HOST: web2.nginx-proxy.local
VIRTUAL_HOST: web2.nginx-proxy.example
4 changes: 2 additions & 2 deletions test/test_custom/test_proxy-wide.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ def test_custom_conf_does_not_apply_to_unknown_vhost(docker_compose, nginxproxy)
assert "X-test" not in r.headers

def test_custom_conf_applies_to_web1(docker_compose, nginxproxy):
r = nginxproxy.get("http://web1.nginx-proxy.local/port")
r = nginxproxy.get("http://web1.nginx-proxy.example/port")
assert r.status_code == 200
assert r.text == "answer from port 81\n"
assert "X-test" in r.headers
assert "f00" == r.headers["X-test"]

def test_custom_conf_applies_to_web2(docker_compose, nginxproxy):
r = nginxproxy.get("http://web2.nginx-proxy.local/port")
r = nginxproxy.get("http://web2.nginx-proxy.example/port")
assert r.status_code == 200
assert r.text == "answer from port 82\n"
assert "X-test" in r.headers
Expand Down
4 changes: 2 additions & 2 deletions test/test_custom/test_proxy-wide.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ services:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: web1.nginx-proxy.local
VIRTUAL_HOST: web1.nginx-proxy.example

web2:
image: web
expose:
- "82"
environment:
WEB_PORTS: 82
VIRTUAL_HOST: web2.nginx-proxy.local
VIRTUAL_HOST: web2.nginx-proxy.example
4 changes: 2 additions & 2 deletions test/test_internal/test_internal-per-vhost.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import pytest

def test_network_web1(docker_compose, nginxproxy):
r = nginxproxy.get("http://web1.nginx-proxy.local/port")
r = nginxproxy.get("http://web1.nginx-proxy.example/port")
assert r.status_code == 200
assert r.text == "answer from port 81\n"
assert "X-network" in r.headers
assert "internal" == r.headers["X-network"]

def test_network_web2(docker_compose, nginxproxy):
r = nginxproxy.get("http://web2.nginx-proxy.local/port")
r = nginxproxy.get("http://web2.nginx-proxy.example/port")
assert r.status_code == 200
assert r.text == "answer from port 82\n"
assert "X-network" not in r.headers
4 changes: 2 additions & 2 deletions test/test_internal/test_internal-per-vhost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ web1:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: web1.nginx-proxy.local
VIRTUAL_HOST: web1.nginx-proxy.example
NETWORK_ACCESS: internal

web2:
Expand All @@ -13,7 +13,7 @@ web2:
- "82"
environment:
WEB_PORTS: 82
VIRTUAL_HOST: web2.nginx-proxy.local
VIRTUAL_HOST: web2.nginx-proxy.example

sut:
image: nginxproxy/nginx-proxy:test
Expand Down
4 changes: 2 additions & 2 deletions test/test_internal/test_internal-per-vpath.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import pytest

def test_network_web1(docker_compose, nginxproxy):
r = nginxproxy.get("http://nginx-proxy.local/web1/port")
r = nginxproxy.get("http://nginx-proxy.example/web1/port")
assert r.status_code == 200
assert r.text == "answer from port 81\n"
assert "X-network" in r.headers
assert "internal" == r.headers["X-network"]

def test_network_web2(docker_compose, nginxproxy):
r = nginxproxy.get("http://nginx-proxy.local/web2/port")
r = nginxproxy.get("http://nginx-proxy.example/web2/port")
assert r.status_code == 200
assert r.text == "answer from port 82\n"
assert "X-network" not in r.headers
4 changes: 2 additions & 2 deletions test/test_internal/test_internal-per-vpath.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ web1:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: nginx-proxy.local
VIRTUAL_HOST: nginx-proxy.example
VIRTUAL_PATH: /web1/
VIRTUAL_DEST: /
NETWORK_ACCESS: internal
Expand All @@ -15,7 +15,7 @@ web2:
- "82"
environment:
WEB_PORTS: 82
VIRTUAL_HOST: nginx-proxy.local
VIRTUAL_HOST: nginx-proxy.example
VIRTUAL_PATH: /web2/
VIRTUAL_DEST: /

Expand Down
4 changes: 2 additions & 2 deletions test/test_multiple-networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ def test_unknown_virtual_host(docker_compose, nginxproxy):
assert r.status_code == 503

def test_forwards_to_web1(docker_compose, nginxproxy):
r = nginxproxy.get("http://web1.nginx-proxy.local/port")
r = nginxproxy.get("http://web1.nginx-proxy.example/port")
assert r.status_code == 200
assert r.text == "answer from port 81\n"

def test_forwards_to_web2(docker_compose, nginxproxy):
r = nginxproxy.get("http://web2.nginx-proxy.local/port")
r = nginxproxy.get("http://web2.nginx-proxy.example/port")
assert r.status_code == 200
assert r.text == "answer from port 82\n"

Expand Down
4 changes: 2 additions & 2 deletions test/test_multiple-networks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ services:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: web1.nginx-proxy.local
VIRTUAL_HOST: web1.nginx-proxy.example
networks:
- net1

Expand All @@ -33,7 +33,7 @@ services:
- "82"
environment:
WEB_PORTS: 82
VIRTUAL_HOST: web2.nginx-proxy.local
VIRTUAL_HOST: web2.nginx-proxy.example
networks:
- net2

Expand Down
2 changes: 1 addition & 1 deletion test/test_vhost-in-multiple-networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import time

def test_forwards_to_web1(docker_compose, nginxproxy):
r = nginxproxy.get("http://web1.nginx-proxy.local/port")
r = nginxproxy.get("http://web1.nginx-proxy.example/port")
assert r.status_code == 200
assert r.text == "answer from port 81\n"

Expand Down
2 changes: 1 addition & 1 deletion test/test_vhost-in-multiple-networks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:
- "81"
environment:
WEB_PORTS: 81
VIRTUAL_HOST: web1.nginx-proxy.local
VIRTUAL_HOST: web1.nginx-proxy.example
networks:
- net1
- net2
Expand Down

0 comments on commit b382d0b

Please sign in to comment.