Possible bug with cached redirects and chunked encoding
sfussenegger
nginx-forum at nginx.us
Wed Jan 13 20:05:24 MSK 2010
Hi all,
I have a problem using nginx as reverse proxy cache (in front of Jetty).
Depending on the client, a redirect from cache takes either very long to complete or fails (curl: (18) transfer closed with outstanding read data remaining) - only chrome works as expected.
It looks like a redirect from cache doesn't play nicely with "Transfer-Encoding: chunked". Using Wireshark, I've seen that no empty chunk follows the header after a cache hit. I'd bet that this is illegal (and handled differently in different clients - hence the different behavior).
Is this a known issue? Or is there a patch available? As a quick workaround, I've disabled caching of redirects.
some config snippets:
# 1st snippet
server {
# snip
proxy_cache myapp;
proxy_cache_valid 200 302 30m;
proxy_cache_valid 301 1h;
proxy_cache_use_stale updating;
proxy_cache_key "$scheme$host$request_uri";
add_header X-Upstream-Cache-Status $upstream_cache_status;
}
# 2nd snippet
location / {
# snip
proxy_pass http://backend;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass_header Set-Cookie;
}
# 3rd snippet
http {
# snip
gzip on;
gzip_disable msie6;
proxy_cache_path /tmp/nginx-cache levels=1:2 keys_zone=myapp:10m inactive=60m max_size=1000m;
}
First request to a cached resource:
$ curl -i http://local.example.com/script/all.js
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Wed, 13 Jan 2010 16:13:57 GMT
Transfer-Encoding: chunked
Connection: keep-alive
Location: http://www.local.example.com/script/all.js
X-Upstream-Cache-Status: MISS
Second request to a cached resource:
$ curl -i http://local.example.com/script/all.js
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Wed, 13 Jan 2010 16:15:02 GMT
Transfer-Encoding: chunked
Connection: keep-alive
Location: http://www.local.example.com/script/all.js
X-Upstream-Cache-Status: HIT
curl: (18) transfer closed with outstanding read data remaining
Request to backend server:
$ curl -i http://local.example.com:8082/script/all.js
HTTP/1.1 301 Moved Permanently
Date: Wed, 13 Jan 2010 16:33:15 GMT
Location: http://www.local.example.com/script/all.js
Content-Length: 0
Cheers, Stefan
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,40752,40752#msg-40752
More information about the nginx
mailing list