-
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.
Merge pull request #2222 from rot169/support-hostnet-containers
Support containers running --net=host (#1537)
- Loading branch information
Showing
7 changed files
with
115 additions
and
0 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,13 @@ | ||
import pytest | ||
|
||
|
||
def test_forwards_to_bridge_network_container(docker_compose, nginxproxy): | ||
r = nginxproxy.get("http://bridge-network.nginx-proxy.tld/port") | ||
assert r.status_code == 200 | ||
assert r.text == "answer from port 80\n" | ||
|
||
|
||
def test_forwards_to_host_network_container(docker_compose, nginxproxy): | ||
r = nginxproxy.get("http://host-network.nginx-proxy.tld/port") | ||
assert r.status_code == 200 | ||
assert r.text == "answer from port 8080\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,31 @@ | ||
version: "2" | ||
|
||
networks: | ||
net1: | ||
internal: true | ||
net2: | ||
|
||
services: | ||
bridge-network: | ||
image: web | ||
environment: | ||
WEB_PORTS: "80" | ||
VIRTUAL_HOST: "bridge-network.nginx-proxy.tld" | ||
networks: | ||
- net2 | ||
|
||
host-network: | ||
image: web | ||
environment: | ||
WEB_PORTS: "8080" | ||
VIRTUAL_HOST: "host-network.nginx-proxy.tld" | ||
VIRTUAL_PORT: "8080" | ||
network_mode: host | ||
|
||
sut: | ||
image: nginxproxy/nginx-proxy:test | ||
volumes: | ||
- /var/run/docker.sock:/tmp/docker.sock:ro | ||
networks: | ||
- net1 | ||
- net2 |
13 changes: 13 additions & 0 deletions
13
test/test_host-network-mode/test_proxy-host-network-mode.py
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,13 @@ | ||
import pytest | ||
|
||
|
||
def test_forwards_to_host_network_container_1(docker_compose, nginxproxy): | ||
r = nginxproxy.get("http://host-network-1.nginx-proxy.tld:8888/port") | ||
assert r.status_code == 200 | ||
assert r.text == "answer from port 8080\n" | ||
|
||
|
||
def test_forwards_to_host_network_container_2(docker_compose, nginxproxy): | ||
r = nginxproxy.get("http://host-network-2.nginx-proxy.tld:8888/port") | ||
assert r.status_code == 200 | ||
assert r.text == "answer from port 8181\n" |
26 changes: 26 additions & 0 deletions
26
test/test_host-network-mode/test_proxy-host-network-mode.yml
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,26 @@ | ||
version: "2" | ||
|
||
services: | ||
host-network-1: | ||
image: web | ||
environment: | ||
WEB_PORTS: "8080" | ||
VIRTUAL_HOST: "host-network-1.nginx-proxy.tld" | ||
VIRTUAL_PORT: "8080" | ||
network_mode: host | ||
|
||
host-network-2: | ||
image: web | ||
environment: | ||
WEB_PORTS: "8181" | ||
VIRTUAL_HOST: "host-network-2.nginx-proxy.tld" | ||
VIRTUAL_PORT: "8181" | ||
network_mode: host | ||
|
||
sut: | ||
image: nginxproxy/nginx-proxy:test | ||
volumes: | ||
- /var/run/docker.sock:/tmp/docker.sock:ro | ||
environment: | ||
HTTP_PORT: 8888 | ||
network_mode: host |