Проблема с curl, proxy cache и Content-Lenght
ddr400
nginx-forum at nginx.us
Wed Mar 5 12:44:11 UTC 2014
Всем привет!
Столкнулся с неожиданной проблемой. Если включен proxy_cache и используется
ssi, curl часто выдает ошибку
* Received problem 3 in the chunky parser
* Closing connection #0
curl: (56) Received problem 3 in the chunky parser
и в error.log:
2014/03/05 16:33:55 [info] 31373#0: *525 client prematurely closed
connection while sending to client, client: 1.1.1.1, server: host.ru,
request: "GET / HTTP/1.1", subrequest: "/includes/lists/tabloid", upstream:
"http://127.0.0.1:9030/includes/lists/tabloid", host: "host.ru"
Все начинает правильно работать, при следующих условиях:
1. ssi off и тогда nginx начинает передавать curl заголовок Content-Lenght
2. proxy_cache не используется и ssi on
Конфиг:
ssi on;
gzip_static on;
keepalive_requests 20;
location ~ ^/includes {
include /etc/nginx/conf/access.conf;
proxy_cache some-cache;
proxy_cache_valid 200 302 301 304 10s;
proxy_cache_key "$request_method|$host|$uri";
proxy_hide_header "Set-Cookie";
proxy_ignore_headers "Cache-Control" "Expires";
proxy_cache_use_stale error timeout invalid_header updating
http_500 http_502 http_503;
proxy_cache_lock on;
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
proxy_set_header Accept text/html;
proxy_set_header Host host.ru;
proxy_pass http://localhost:9030;
}
location / {
proxy_cache some-cache;
proxy_cache_valid 200 302 301 304 30s;
proxy_cache_key "$request_method|$host|$uri";
proxy_hide_header "Set-Cookie";
proxy_ignore_headers "Cache-Control" "Expires";
proxy_cache_use_stale error timeout invalid_header updating
http_500 http_502 http_503;
proxy_cache_lock on;
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
proxy_set_header Accept text/html;
proxy_set_header Host host.ru;
proxy_pass http://localhost:9030;
}
Заголовки приложения:
< HTTP/1.1 200 OK
< Date: Wed, 05 Mar 2014 12:38:37 GMT
< Status: 200 OK
< Connection: close
< Content-Type: text/html; charset=utf-8
< Content-Length: 20041
< X-UA-Compatible: IE=Edge,chrome=1
< ETag: "8bdee631c5839fef72100f192025570b"
< Cache-Control: max-age=0, private, must-revalidate
< X-Request-Id: bd50bffa8386d8c870448d47f2f00941
< X-Runtime: 0.116565
Заголовки которые отдает nginx:
< HTTP/1.1 200 OK
< Server: nginx
< Date: Wed, 05 Mar 2014 12:38:11 GMT
< Content-Type: text/html; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Vary: Accept-Encoding
< Status: 200 OK
< X-UA-Compatible: IE=Edge,chrome=1
< Cache-Control: max-age=0, private, must-revalidate
< X-Request-Id: 5238e092ddcf2a4b83e527fda2892145
< X-Runtime: 0.098263
Posted at Nginx Forum: http://forum.nginx.org/read.php?21,248133,248133#msg-248133
Подробная информация о списке рассылки nginx-ru