aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/ngx_http_proxy_module.c
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2013-02-18 13:50:52 +0000
committerMaxim Dounin <mdounin@mdounin.ru>2013-02-18 13:50:52 +0000
commit08a73b4aadebd9405ac52ec1f6eef5ca1fe8c11a (patch)
tree844f6f53431a2c5071b7a799a697b26631946db9 /src/http/modules/ngx_http_proxy_module.c
parent35c17ea6f55c202956dccdf11edcdcda432edebe (diff)
downloadnginx-08a73b4aadebd9405ac52ec1f6eef5ca1fe8c11a.tar.gz
nginx-08a73b4aadebd9405ac52ec1f6eef5ca1fe8c11a.zip
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.
Diffstat (limited to 'src/http/modules/ngx_http_proxy_module.c')
-rw-r--r--src/http/modules/ngx_http_proxy_module.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c
index ce47a9e34..a623adc34 100644
--- a/src/http/modules/ngx_http_proxy_module.c
+++ b/src/http/modules/ngx_http_proxy_module.c
@@ -1474,6 +1474,14 @@ ngx_http_proxy_process_header(ngx_http_request_t *r)
u->keepalive = !u->headers_in.connection_close;
}
+ if (u->headers_in.status_n == NGX_HTTP_SWITCHING_PROTOCOLS) {
+ u->keepalive = 0;
+
+ if (r->headers_in.upgrade) {
+ u->upgrade = 1;
+ }
+ }
+
return NGX_OK;
}