Welcome! Log In Create A New Profile

Advanced

Re: nginx незавершаетсоединениепослевыд ачиответачерезinternal_redirect()?

September 08, 2009 06:32AM
On Tue, Sep 08, 2009 at 09:49:50AM +0000, Igor Afanasyev wrote:

> Всем добрый день!
>
> Столкнулся со следующей проблемой, которая выглядит как явный баг nginx.
>
> Конфигурация:
> CentOS,
> nginx/0.8.14 c perl-модулем
> perl 5.8.8
>
> Есть простейший Perl-модуль, который настроен на обработку URL определенного
> типа:
>
> =[foo.pm]==============================
> package foo;
>
> use nginx;
>
> sub handler {
> my $r = shift;
> $r->internal_redirect('/foo.shtml');
> return OK;
> }
>
> 1; # return true
> =[/foo.pm]=============================
>
> Упрощенный site.conf (выписал те директивы, которые имеют отношение к делу):
>
> =[site.conf]===========================
> perl_modules /path/to/my/lib
> perl_require foo.pm
>
> location ~* \.xml$ {
> perl foo::handler;
> }
>
> location ~* \.shtml$ {
> expires -1;
> ssi on;
> root /var/www/html;
> }
>
> =[/site.conf]==========================
>
> Когда делаю "wget -S http://localhost/foo.shtml", все нормально, файл отдается..
>
> Когда делаю "wget -S http://localhost/bar.xml", nginx отдает заголовки и само
> тело файла foo.shtml (условно, 500 байт -- это wget показывает), но потом
> соединение не закрывается и wget ждет окончания посылки файла бесконечно (до
> таймаута wget). При этом в заголовках не прописан размер файла foo.shtml.
>
> В error_log (который у меня включен в режиме debug) видна такая картина:
>
> =[error_log]===========================
> 2009/09/08 05:09:59 [notice] 29032#0: *1 "^/(.*)\.shtml$" matches "/foo..shtml",
> client: XX.XX.XX.XX, server: XXXXXX.com, request: "GET /bar.xml HTTP/1.1", host:
> "XXXXXX.com:81"
> =[/error_log]==========================
>
> Т.е. internal_redirect() срабатывает, правило location срабатывает. в access_log
> при этом записи никакой не появляется (пока клиент не отвалится по таймауту).
>
> Пробовал отключать gzip, ssi и прочее -- проблема не исчезает. Даже не знаю,
> куда копать. Есть смысл ставить nginx 0.7.61?

В 0.7.61 должно работать. Для 0.8.14 нужен прилагаемый патч.


--
Игорь Сысоев
http://sysoev.ru
Index: src/http/ngx_http_upstream.c
===================================================================
--- src/http/ngx_http_upstream.c (revision 2430)
+++ src/http/ngx_http_upstream.c (working copy)
@@ -363,6 +363,7 @@
u = r->upstream;

if (u && u->cleanup) {
+ r->main->count++;
ngx_http_upstream_cleanup(r);
*u->cleanup = NULL;
}
Index: src/http/modules/perl/ngx_http_perl_module.c
===================================================================
--- src/http/modules/perl/ngx_http_perl_module.c (revision 2430)
+++ src/http/modules/perl/ngx_http_perl_module.c (working copy)
@@ -262,6 +262,7 @@

if (uri.len) {
ngx_http_internal_redirect(r, &uri, &args);
+ ngx_http_finalize_request(r, NGX_DONE);
return;
}
Subject Author Posted

nginx незавершаетсоединениепослевыда чиответачерезinternal_redirect()?

Igor Afanasyev September 08, 2009 06:08AM

Re: nginx незавершаетсоединениепослевыд ачиответачерезinternal_redirect()?

Igor Sysoev September 08, 2009 06:32AM

Re: nginx не завершает соединение после выдачи ответа через internal_redirect()?

Igor Afanasyev September 08, 2009 06:48AM

Re: nginx не завершает соединение после выдачи ответа через internal_redirect()?

Igor Sysoev September 08, 2009 07:52AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 176
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready