From 08a73b4aadebd9405ac52ec1f6eef5ca1fe8c11a Mon Sep 17 00:00:00 2001 From: Maxim Dounin Date: Mon, 18 Feb 2013 13:50:52 +0000 Subject: Proxy: support for connection upgrade (101 Switching Protocols). This allows to proxy WebSockets by using configuration like this: location /chat/ { proxy_pass http://backend; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } Connection upgrade is allowed as long as it was requested by a client via the Upgrade request header. --- src/http/ngx_http_variables.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/http/ngx_http_variables.c') diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c index 0c6872fe2..b8190b030 100644 --- a/src/http/ngx_http_variables.c +++ b/src/http/ngx_http_variables.c @@ -1747,7 +1747,11 @@ ngx_http_variable_sent_connection(ngx_http_request_t *r, size_t len; char *p; - if (r->keepalive) { + if (r->headers_out.status == NGX_HTTP_SWITCHING_PROTOCOLS) { + len = sizeof("upgrade") - 1; + p = "upgrade"; + + } else if (r->keepalive) { len = sizeof("keep-alive") - 1; p = "keep-alive"; -- cgit v1.2.3