Vladimir Aliokhin | 1 Mar 01:48
Picon

Непонятное поведение try_files в 0.7.38

Здравствуйте.

Возникла непонятная проблема при использовании
инструкции try_files  в 0.7.38.
Когда длина uri равняется 34 символам nginx возвращает
ответ нулевой
длины, Допустим урл
http://xxx.x.xxx.xxx/12345678901234567890123456789.htm не вернет
ничего. Если как-нибудь изменить uri (добавить или
удалить какой-либо
символ) все начинает работать.

В 0.6.35 с патчем для try_files такой проблемы нет.

--

-- 
Vladimir Aliokhin

Непонятное поведение try_files

location / {
	try_files $uri $uri/ /index.php5;
}

                 location                        ~* \.php5$ {
                         include                         include/ 
fastcgi_param;
                         include                         include/error;
                         fastcgi_index                   index.php5;
                         fastcgi_pass_request_body       off;
                         client_body_in_file_only        clean;
                         fastcgi_pass                    127.0.0.1:9005;
                 }

при отсутствии всего перечисленного  
получаем внутренний редирект на /index.php5  
и его последующую нормальную  
обработку ( /index.php5 в $document_root существует  
и доступен )

location / {
	try_files $uri $uri/ /index.php5 что- 
либо_ещё_в_любых_количествах;
}

                 location                        ~* \.php5$ {
                         include                         include/ 
fastcgi_param;
                         include                         include/error;
                         fastcgi_index                   index.php5;
(Continue reading)

Maxim Dounin | 1 Mar 09:16
Picon

Re: Непонятное поведение try_files

Hello!

On Sun, Mar 01, 2009 at 05:49:14AM +0300, Alexey V. Karagodov wrote:

> location / {
> 	try_files $uri $uri/ /index.php5;
> }

[...]

> при отсутствии всего перечисленного получаем
внутренний редирект на 
> /index.php5 и его последующую нормальную обработку (
/index.php5 в 
> $document_root существует и доступен )
>
> location / {
> 	try_files $uri $uri/ /index.php5 что-либо_ещё_в_любых_количествах;
> }

[...]

> а в таком варианте конфига получаем содержимое /index.php5
> что не так?

http://sysoev.ru/nginx/docs/http/ngx_http_core_module.html#try_files

syntax: try_files файл [файл ...] uri

Maxim Dounin
(Continue reading)

Maxim Dounin | 1 Mar 09:25
Picon

Re: Непонятное поведение try_files в 0.7.38

Hello!

On Sun, Mar 01, 2009 at 02:48:37AM +0200, Vladimir Aliokhin wrote:

> Здравствуйте.
> 
> Возникла непонятная проблема при использовании
инструкции try_files  в 0.7.38.
> Когда длина uri равняется 34 символам nginx возвращает
ответ нулевой
> длины, Допустим урл
> http://xxx.x.xxx.xxx/12345678901234567890123456789.htm не вернет
> ничего. Если как-нибудь изменить uri (добавить или
удалить какой-либо
> символ) все начинает работать.
> 
> В 0.6.35 с патчем для try_files такой проблемы нет.

Было бы замечательно, если бы вы показали конфиг, с
которым  
проблема воспроизводится, и сделали debug log для двух
запросов - 
возвращающего ответ нулевой длины и нормального.

Maxim Dounin

Igor Sysoev | 1 Mar 09:34
Picon

Re: Непонятное поведение try_files

On Sun, Mar 01, 2009 at 05:49:14AM +0300, Alexey V. Karagodov wrote:

> location / {
> 	try_files $uri $uri/ /index.php5;
> }
> 
>                 location                        ~* \.php5$ {
>                         include                         include/ 
> fastcgi_param;
>                         include                         include/error;
>                         fastcgi_index                   index.php5;
>                         fastcgi_pass_request_body       off;
>                         client_body_in_file_only        clean;
>                         fastcgi_pass                    127.0.0.1:9005;
>                 }
> 
> при отсутствии всего перечисленного  
> получаем внутренний редирект на /index.php5  
> и его последующую нормальную  
> обработку ( /index.php5 в $document_root существует  
> и доступен )
> 
> location / {
> 	try_files $uri $uri/ /index.php5 что- 
> либо_ещё_в_любых_количествах;
> }
> 
>                 location                        ~* \.php5$ {
>                         include                         include/ 
> fastcgi_param;
(Continue reading)

Re: Непонятное поведение try_files


On 01.03.2009, at 11:34, Igor Sysoev wrote:

> On Sun, Mar 01, 2009 at 05:49:14AM +0300, Alexey V. Karagodov wrote:
>
>> location / {
>> 	try_files $uri $uri/ /index.php5;
>> }
>>
>>                location                        ~* \.php5$ {
>>                        include                         include/
>> fastcgi_param;
>>                        include                         include/error;
>>                        fastcgi_index                   index.php5;
>>                        fastcgi_pass_request_body       off;
>>                        client_body_in_file_only        clean;
>>                        fastcgi_pass                     
>> 127.0.0.1:9005;
>>                }
>>
>> при отсутствии всего перечисленного
>> получаем внутренний редирект на /index.php5
>> и его последующую нормальную
>> обработку ( /index.php5 в $document_root существует
>> и доступен )
>>
>> location / {
>> 	try_files $uri $uri/ /index.php5 что-
>> либо_ещё_в_любых_количествах;
>> }
(Continue reading)

Igor Sysoev | 1 Mar 12:10
Picon

Re: Непонятное поведение try_files

On Sun, Mar 01, 2009 at 01:12:23PM +0300, Alexey V. Karagodov wrote:

> 
> On 01.03.2009, at 11:34, Igor Sysoev wrote:
> 
> >On Sun, Mar 01, 2009 at 05:49:14AM +0300, Alexey V. Karagodov wrote:
> >
> >>location / {
> >>	try_files $uri $uri/ /index.php5;
> >>}
> >>
> >>               location                        ~* \.php5$ {
> >>                       include                         include/
> >>fastcgi_param;
> >>                       include                         include/error;
> >>                       fastcgi_index                   index.php5;
> >>                       fastcgi_pass_request_body       off;
> >>                       client_body_in_file_only        clean;
> >>                       fastcgi_pass                     
> >>127.0.0.1:9005;
> >>               }
> >>
> >>при отсутствии всего перечисленного
> >>получаем внутренний редирект на /index.php5
> >>и его последующую нормальную
> >>обработку ( /index.php5 в $document_root существует
> >>и доступен )
> >>
> >>location / {
> >>	try_files $uri $uri/ /index.php5 что-
(Continue reading)

Re: Непонятное поведение try_files

Attachment (debug.log.bz2): application/x-bzip2, 17 KiB

server  {
  access_log /srv/logs/nginx/test.net-profit.ru.log  combined;
  error_log /srv/logs/nginx/test.net-profit.ru.log  debug;
  server_name test.net-profit.ru;
  set $_document_root /srv/devel/sync/starstory/core;

  include include/rewrite;
  include include/listen_http;
  include include/error;
  include include/location_error;

  root $_document_root;

# location ~* \.(jpg|png|xml|txt|jpeg|gif|js|swf|css|pdf|doc|log|mms| 
xml|config|sh|inc|ico)$ {
# }
  location ~* \.php5$ {
   try_files $uri @PHP5;
   include include/fastcgi_param;
   fastcgi_index index.php5;
   fastcgi_pass_request_body off;
   client_body_in_file_only clean;
   fastcgi_pass php5-cluster;
  }
   location / {
   try_files /index.html $uri $uri/ @PHP5;
  }
  location @PHP5 {
   include include/fastcgi_param;
   include include/error;
   include include/error_ERROR_PAGE_404;
   fastcgi_param SCRIPT_FILENAME $_document_root/index.php5;
   fastcgi_pass_request_body off;
   client_body_in_file_only clean;
   fastcgi_pass php5-cluster;
  }
}

как выяснилось, вокеры падают если закоментировать
location  
описывающий статику
если комменты убрать, то всё нормально
однако, большой нагрузки на сервер нет
nginx-devel установлен из портов, все опции включены кроме
google perf  
tools

P.S.: сорри за форматирование, в моём почтовом клиенте
всё  
отображается нормально
P.P.S.: сейчас нормально выглядит?

On 01.03.2009, at 14:10, Igor Sysoev wrote:

> On Sun, Mar 01, 2009 at 01:12:23PM +0300, Alexey V. Karagodov wrote:
>
>>
>> On 01.03.2009, at 11:34, Igor Sysoev wrote:
>>
>>> On Sun, Mar 01, 2009 at 05:49:14AM +0300, Alexey V. Karagodov wrote:
>>>
>>>> location / {
>>>> 	try_files $uri $uri/ /index.php5;
>>>> }
>>>>
>>>>              location                        ~* \.php5$ {
>>>>                      include                         include/
>>>> fastcgi_param;
>>>>                      include                         include/error;
>>>>                      fastcgi_index                   index.php5;
>>>>                      fastcgi_pass_request_body       off;
>>>>                      client_body_in_file_only        clean;
>>>>                      fastcgi_pass
>>>> 127.0.0.1:9005;
>>>>              }
>>>>
>>>> при отсутствии всего перечисленного
>>>> получаем внутренний редирект на /index.php5
>>>> и его последующую нормальную
>>>> обработку ( /index.php5 в $document_root существует
>>>> и доступен )
>>>>
>>>> location / {
>>>> 	try_files $uri $uri/ /index.php5 что-
>>>> либо_ещё_в_любых_количествах;
>>>> }
>>>>
>>>>              location                        ~* \.php5$ {
>>>>                      include                         include/
>>>> fastcgi_param;
>>>>                      include                         include/error;
>>>>                      fastcgi_index                   index.php5;
>>>>                      fastcgi_pass_request_body       off;
>>>>                      client_body_in_file_only        clean;
>>>>                      fastcgi_pass
>>>> 127.0.0.1:9005;
>>>>              }
>>>>
>>>> а в таком варианте конфига получаем
>>>> содержимое /index.php5
>>>> что не так?
>>>
>>> Максим уже ответил, а я лишь хочу сказать, что с
каждым днём я всё
>>> больше
>>> понимаю Гвидо ван Россума.
>> я не в курсе
>
> Конфигурации
>                                                         вида
> location / {
> 	try_files $uri $uri/ /index.php5;
> }
>               location                        ~* \.php5$ {
>                       include                         include/
> fastcgi_param;
>                                                                    
> очень
> не
>                               удобно
> читать.
>
>>>
>>>
>> вокеры нгинх кстати падают при обработке такой конструкции
>> debug_log или что-то ещё нужно?
>
> Да, нужен отладочный лог.
>
>
> -- 
> Игорь Сысоев
> http://sysoev.ru
>

Fwd: Непонятное поведение try_files


Begin forwarded message:

> From: "Alexey V. Karagodov" <kav@...>
> Date: 1 марта 2009 г. 15:49:57 GMT+03:00
> To: nginx-ru@...
> Subject: Re: Непонятное поведение try_files
>
>
>
>
> server  {
> access_log /srv/logs/nginx/test.net-profit.ru.log  combined;
> error_log /srv/logs/nginx/test.net-profit.ru.log  debug;
> server_name test.net-profit.ru;
> set $_document_root /srv/devel/sync/starstory/core;
>
> include include/rewrite;
> include include/listen_http;
> include include/error;
> include include/location_error;
>
> root $_document_root;
>
> # location ~* \.(jpg|png|xml|txt|jpeg|gif|js|swf|css|pdf|doc|log|mms| 
> xml|config|sh|inc|ico)$ {
> # }
> location ~* \.php5$ {
>  try_files $uri @PHP5;
>  include include/fastcgi_param;
>  fastcgi_index index.php5;
>  fastcgi_pass_request_body off;
>  client_body_in_file_only clean;
>  fastcgi_pass php5-cluster;
> }
>  location / {
>  try_files /index.html $uri $uri/ @PHP5;
> }
> location @PHP5 {
>  include include/fastcgi_param;
>  include include/error;
>  include include/error_ERROR_PAGE_404;
>  fastcgi_param SCRIPT_FILENAME $_document_root/index.php5;
>  fastcgi_pass_request_body off;
>  client_body_in_file_only clean;
>  fastcgi_pass php5-cluster;
> }
> }
>
> как выяснилось, вокеры падают если закоментировать
location  
> описывающий статику
> если комменты убрать, то всё нормально
> однако, большой нагрузки на сервер нет
под нагрузкой вокеры таки падают при любом варианте конфигурации

> nginx-devel установлен из портов, все опции включены
кроме google  
> perf tools
>
> P.S.: сорри за форматирование, в моём почтовом клиенте
всё  
> отображается нормально
> P.P.S.: сейчас нормально выглядит?
>
>
> On 01.03.2009, at 14:10, Igor Sysoev wrote:
>
>> On Sun, Mar 01, 2009 at 01:12:23PM +0300, Alexey V. Karagodov wrote:
>>
>>>
>>> On 01.03.2009, at 11:34, Igor Sysoev wrote:
>>>
>>>> On Sun, Mar 01, 2009 at 05:49:14AM +0300, Alexey V. Karagodov  
>>>> wrote:
>>>>
>>>>> location / {
>>>>> 	try_files $uri $uri/ /index.php5;
>>>>> }
>>>>>
>>>>>             location                        ~* \.php5$ {
>>>>>                     include                         include/
>>>>> fastcgi_param;
>>>>>                     include                         include/error;
>>>>>                     fastcgi_index                   index.php5;
>>>>>                     fastcgi_pass_request_body       off;
>>>>>                     client_body_in_file_only        clean;
>>>>>                     fastcgi_pass
>>>>> 127.0.0.1:9005;
>>>>>             }
>>>>>
>>>>> при отсутствии всего перечисленного
>>>>> получаем внутренний редирект на /index.php5
>>>>> и его последующую нормальную
>>>>> обработку ( /index.php5 в $document_root существует
>>>>> и доступен )
>>>>>
>>>>> location / {
>>>>> 	try_files $uri $uri/ /index.php5 что-
>>>>> либо_ещё_в_любых_количествах;
>>>>> }
>>>>>
>>>>>             location                        ~* \.php5$ {
>>>>>                     include                         include/
>>>>> fastcgi_param;
>>>>>                     include                         include/error;
>>>>>                     fastcgi_index                   index.php5;
>>>>>                     fastcgi_pass_request_body       off;
>>>>>                     client_body_in_file_only        clean;
>>>>>                     fastcgi_pass
>>>>> 127.0.0.1:9005;
>>>>>             }
>>>>>
>>>>> а в таком варианте конфига получаем
>>>>> содержимое /index.php5
>>>>> что не так?
>>>>
>>>> Максим уже ответил, а я лишь хочу сказать, что с
каждым днём я всё
>>>> больше
>>>> понимаю Гвидо ван Россума.
>>> я не в курсе
>>
>> Конфигурации
>>                                                        вида
>> location / {
>> 	try_files $uri $uri/ /index.php5;
>> }
>>              location                        ~* \.php5$ {
>>                      include                         include/
>> fastcgi_param;
>>                                                                   
>> очень
>> не
>>                              удобно
>> читать.
>>
>>>>
>>>>
>>> вокеры нгинх кстати падают при обработке такой конструкции
>>> debug_log или что-то ещё нужно?
>>
>> Да, нужен отладочный лог.
>>
>>
>> -- 
>> Игорь Сысоев
>> http://sysoev.ru
>>
>

Igor Sysoev | 1 Mar 19:10
Picon

Re: Непонятное поведение try_files

On Sun, Mar 01, 2009 at 03:49:57PM +0300, Alexey V. Karagodov wrote:

> server  {
>  access_log /srv/logs/nginx/test.net-profit.ru.log  combined;
>  error_log /srv/logs/nginx/test.net-profit.ru.log  debug;
>  server_name test.net-profit.ru;
>  set $_document_root /srv/devel/sync/starstory/core;
> 
>  include include/rewrite;
>  include include/listen_http;
>  include include/error;
>  include include/location_error;
> 
>  root $_document_root;

А зачем такой root ?

> как выяснилось, вокеры падают если закоментировать
location  
> описывающий статику
> если комменты убрать, то всё нормально
> однако, большой нагрузки на сервер нет
> nginx-devel установлен из портов, все опции включены
кроме google perf  
> tools

Патч.

> P.S.: сорри за форматирование, в моём почтовом клиенте
всё  
> отображается нормально

Вот как это выглядит:

http://www.lexa.ru/nginx-ru/msg22457.html

> P.P.S.: сейчас нормально выглядит?

Да.

-- 
Игорь Сысоев
http://sysoev.ru
Index: src/http/ngx_http_core_module.c
===================================================================
--- src/http/ngx_http_core_module.c	(revision 1860)
+++ src/http/ngx_http_core_module.c	(working copy)
@@ -1086,13 +1086,9 @@
             len = tf->name.len;
         }

-        reserve = len - r->uri.len;
-
         /* 16 bytes are preallocation */
-        reserve = reserve < 16 ? 16 : reserve + 16;
+        reserve = ngx_abs((ssize_t) (len - r->uri.len)) + alias + 16;

-        reserve += alias;
-
         if (reserve > allocated) {

             /* we just need to allocate path and to copy a root */

Gmane