Opened 10 years ago

Closed 10 years ago

#467 closed defect (invalid)

Transfer-Encoding: chunked и proxy_pass

Reported by: Александр Гурьянов Owned by:
Priority: major Milestone:
Component: nginx-core Version:
Keywords: Cc:
uname -a: Linux green 3.5.0-23-generic #35~precise1-Ubuntu SMP Fri Jan 25 17:13:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.4.1
built by gcc 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --with-http_gzip_static_module --with-cc-opt=-Wno-error --user=wwwrun --with-http_addition_module --with-http_stub_status_module --with-http_stub_status_module --with-http_stub_status_module --with-http_realip_module

Description

Добрый день у меня есть приложение на java которое использует в качестве сервера Netty. Это приложение возвращает простой ответ в режиме Transfer-Encoding: chunked. Все прекрасно работает если я использую это приложение напрямую. Когда я ставлю перед ним nginx, то ответ nginx всегда пустой. Настройки nginx у меня такие (http://serverfault.com/questions/159313/enabling-nginx-chunked-transfer-encoding/187573#187573):

location / {

chunked_transfer_encoding on;
proxy_buffering off;
proxy_pass http://127.0.0.1:8000;

}

Тест сервера напрямую:

 curl -v "127.0.0.1:8000"
* About to connect() to 127.0.0.1 port 8000 (#0)
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8000 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: 127.0.0.1:8000
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/plain; charset=UTF-8
< Cache-Control: no-store, no-cache, must-revalidate, max-age=0
< Connection: keep-alive
< Transfer-Encoding: chunked
<
123
* Connection #0 to host 127.0.0.1 left intact

Тест через nginx:

curl -v "127.0.0.1"
* About to connect() to 127.0.0.1 port 80 (#0)
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: 127.0.0.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx/1.2.6 (Ubuntu)
< Date: Mon, 09 Dec 2013 09:54:01 GMT
< Content-Type: text/plain; charset=UTF-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Cache-Control: no-store, no-cache, must-revalidate, max-age=0
<
* Connection #0 to host 127.0.0.1 left intact

Я прогнал все через wireshark, но там тоже информации не много.

TCP stream напрямую:

GET / HTTP/1.1
User-Agent: curl/7.29.0
Host: 127.0.0.1
Accept: */*
 
HTTP/1.1 200 OK
Content-Type: text/plain; charset=UTF-8
Cache-Control: no-store, no-cache, must-revalidate, max-age=0
Connection: keep-alive
Transfer-Encoding: chunked
 
1
1
1
2
1
3
1

 
0 

TCP stream через nginx:

GET / HTTP/1.1
User-Agent: curl/7.29.0
Host: 127.0.0.1
Accept: */*
 
HTTP/1.1 200 OK
Server: nginx/1.2.6 (Ubuntu)
Date: Mon, 09 Dec 2013 10:17:58 GMT
Content-Type: text/plain; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Cache-Control: no-store, no-cache, must-revalidate, max-age=0
 
0 

Архив с приложением https://mega.co.nz/#!KZUR0BqZ!XT7RGXiCcYNkfzGB2cYinlSydZNeSg6UOsFLxpsHcYU

Запускать так:
./script/runner quickstart.Boot

Change History (1)

comment:1 by Maxim Dounin, 10 years ago

Resolution: invalid
Status: newclosed

Простите, но это не то место, куда следует обращаться за помощью. Суда следует писать, если вы нашли ошибку в nginx'е. Если же у вас не получается заставить работать ваше приложение - вы можете попробовать обратиться в список рассылки, см. http://nginx.org/ru/support.html.

Just some quick tips:

  • Судя по приведённой информации - такой ответ вам возвращает приложение, возможно - из-за того, что nginx к нему приходит по HTTP/1.0, а не HTTP/1.1. Можно попробовать воспользоваться директивой proxy_http_version, чтобы ходить к приложению по HTTP/1.1.
  • Использовать директиву chunked_transfer_encoding не нужно, использовать её со значением on - не имеет смысла.
  • Вопрос на stackoverflow, на который вы ссылаетесь, безнадёжно устарел.
Note: See TracTickets for help on using tickets.