Skip to content

Commit 6d56b1e

Browse files
committed
updated the readme with notes the advanced virtual host syntax
1 parent 9e47e30 commit 6d56b1e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Currently this does not work with the new v2 syntax of docker-compose (due to no
2626

2727
### Multiple Ports
2828

29-
If your container exposes multiple ports, nginx-proxy will default to the service running on port 80. If you need to specify a different port, you can set a VIRTUAL_PORT env var to select a different one. If your container only exposes one port and it has a VIRTUAL_HOST env var set, that port will be selected.
29+
If your container exposes multiple ports, nginx-proxy will default to the service running on port 80. If you need to specify a different port, you can set a VIRTUAL_PORT env var to select a different one. If your container only exposes one port and it has a VIRTUAL_HOST env var set, that port will be selected. Or you can try your hand at the Advanced VIRTUAL_HOST syntax.
3030

3131
[1]: https://github.com/jwilder/docker-gen
3232
[2]: http://jasonwilder.com/blog/2014/03/25/automated-nginx-reverse-proxy-for-docker/
@@ -57,6 +57,22 @@ In this example, the `my-nginx-proxy` container will be connected to `my-network
5757

5858
If you would like to connect to your backend using HTTPS instead of HTTP, set `VIRTUAL_PROTO=https` on the backend container.
5959

60+
### Advanced VIRTUAL_HOST syntax
61+
62+
Using the Advanced VIRTUAL_HOST syntax you can specify multiple host names to each go to their own backend port. Basically provides support for VIRTUAL_HOST, VIRTUAL_PORT, and VIRTUAL_PROTO all in one field.
63+
64+
For example, given the following:
65+
66+
```
67+
VIRTUAL_HOST=api.example.com=>http:80,api-admin.example.com=>http:8001,secure.example.com=>https:8443
68+
```
69+
70+
This would yield 3 different server/upstream configurations...
71+
72+
1. Requests for api.example.com would route to this container's port 80 via http
73+
2. Requests for api-admin.example.com would route to this containers port 8001 via http
74+
3. Requests for secure.example.com would route to this containers port 8443 via https
75+
6076
### Default Host
6177

6278
To set the default host for nginx use the env var `DEFAULT_HOST=foo.bar.com` for example
@@ -143,7 +159,7 @@ a 503.
143159

144160
To serve traffic in both SSL and non-SSL modes without redirecting to SSL, you can include the
145161
environment variable `HTTPS_METHOD=noredirect` (the default is `HTTPS_METHOD=redirect`). You can also
146-
disable the non-SSL site entirely with `HTTPS_METHOD=nohttp`.
162+
disable the non-SSL site entirely with `HTTPS_METHOD=nohttp`.
147163

148164
### Basic Authentication Support
149165

0 commit comments

Comments
 (0)