aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules
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
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')
-rw-r--r--src/http/modules/ngx_http_chunked_filter_module.c1
-rw-r--r--src/http/modules/ngx_http_proxy_module.c8
2 files changed, 9 insertions, 0 deletions
diff --git a/src/http/modules/ngx_http_chunked_filter_module.c b/src/http/modules/ngx_http_chunked_filter_module.c
index 94313a8f6..a7dc5bf4d 100644
--- a/src/http/modules/ngx_http_chunked_filter_module.c
+++ b/src/http/modules/ngx_http_chunked_filter_module.c
@@ -62,6 +62,7 @@ ngx_http_chunked_header_filter(ngx_http_request_t *r)
if (r->headers_out.status == NGX_HTTP_NOT_MODIFIED
|| r->headers_out.status == NGX_HTTP_NO_CONTENT
+ || r->headers_out.status < NGX_HTTP_OK
|| r != r->main
|| (r->method & NGX_HTTP_HEAD))
{
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;
}