January 13, 2010 11:48AM
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:
[code]
# 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;
}
[/code]

First request to a cached resource:
[code]
$ 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

[/code]

Second request to a cached resource:
[code]
$ 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
[/code]

Request to backend server:
[code]
$ 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

[/code]


Cheers, Stefan
Subject Author Posted

Possible bug with cached redirects and chunked encoding

sfussenegger January 13, 2010 11:48AM

Re: Possible bug with cached redirects and chunked encoding

Maxim Dounin January 13, 2010 01:10PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 149
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready