Websockets support

Added `Upgrade` and `Connection` headers to the template to allow nginx to [upgrade a request](http://nginx.com/blog/websocket-nginx/). 

```
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
```

These headers are only added if a `WEBSOCKETS` environment variable is defined.
This commit is contained in:
saidimu apale 2014-10-01 13:35:42 -04:00
parent 941f3cc9d2
commit 752b78ce05

View file

@ -40,6 +40,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;
@ -54,7 +55,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 }}