Merge 1b0d9ed28c
into 2c9d9ab74a
This commit is contained in:
commit
b0e2ff6ee3
2 changed files with 17 additions and 1 deletions
|
@ -14,6 +14,12 @@ Then start any containers you want proxied with an env var `VIRTUAL_HOST=subdoma
|
|||
|
||||
Provided your DNS is setup to forward foo.bar.com to the a host running nginx-proxy, the request will be routed to a container with the VIRTUAL_HOST env var set.
|
||||
|
||||
### Websockets support
|
||||
|
||||
To proxy a websockets container, add an env var WEBSOCKETS=1
|
||||
|
||||
$ docker run -e VIRTUAL_HOST=foo.bar.com -e WEBSOCKETS=1 ...
|
||||
|
||||
### Multiple Ports
|
||||
|
||||
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.
|
||||
|
|
12
nginx.tmpl
12
nginx.tmpl
|
@ -45,6 +45,7 @@ upstream {{ $host }} {
|
|||
{{ end }}
|
||||
}
|
||||
|
||||
{{ range $index, $value := $containers }}
|
||||
server {
|
||||
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
|
@ -62,7 +63,16 @@ server {
|
|||
|
||||
# HTTP 1.1 support
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
|
||||
{{/* Only add the websockets Upgrade headers if a WEBSOCKETS env var is set. */}}
|
||||
{{ if $value.Env.WEBSOCKETS }}
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
{{ else }}
|
||||
proxy_set_header Connection "";
|
||||
{{ end }}
|
||||
|
||||
}
|
||||
{{ end }}
|
||||
}
|
||||
{{ end }}
|
||||
|
|
Loading…
Reference in a new issue