Regexp в location

Igor Sysoev is at rambler-co.ru
Sat Nov 7 20:36:43 MSK 2009


On Sat, Nov 07, 2009 at 08:06:11PM +0300, Михаил Монашёв wrote:

> Здравствуйте.
> 
> Почему-то запрос попадает в другой локейшн:
> 
> 2009/11/07 19:59:55 [debug] 87875#0: *4082 http request line: "GET /yandex.ru HTTP/1.1"
> 2009/11/07 19:59:55 [debug] 87875#0: *4082 http uri: "/yandex.ru"
> 2009/11/07 19:59:55 [debug] 87875#0: *4082 http args: ""
> 2009/11/07 19:59:55 [debug] 87875#0: *4082 http exten: "ru"
> 2009/11/07 19:59:55 [debug] 87875#0: *4082 http process request header line
> 2009/11/07 19:59:55 [debug] 87875#0: *4082 http header: "Host: хххх.ru"
> 2009/11/07 19:59:55 [debug] 87875#0: *4082 http header: "Accept: */*"
> 2009/11/07 19:59:55 [debug] 87875#0: *4082 http header: "Pragma: no-cache"
> 2009/11/07 19:59:55 [debug] 87875#0: *4082 http header: "User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)"
> 2009/11/07 19:59:55 [debug] 87875#0: *4082 http header done
> 2009/11/07 19:59:55 [debug] 87875#0: *4082 generic phase: 0
> 2009/11/07 19:59:55 [debug] 87875#0: *4082 add cleanup: 0000000800D3A990
> 2009/11/07 19:59:55 [debug] 87875#0: *4082 generic phase: 1
> 2009/11/07 19:59:55 [debug] 87875#0: *4082 test location: "/"
> 2009/11/07 19:59:55 [debug] 87875#0: *4082 test location: ~ "^/(\w\.\w)$"
> 2009/11/07 19:59:55 [debug] 87875#0: *4082 using configuration "/"
> 
> 
> должен попадать в ^/(\w\.\w)$ , а попадает в / .
> 
>         location / {
>             return 204;
>         }
> 
>         location ~ ^/(\w\.\w)$ {
>             proxy_pass http://$1:80/favicon.ico;
>         }
> 
> Смысл - проксирование фавиконок разных сайтов.

t42:~>pcretest 
PCRE version 7.6 2008-01-28

  re> #^/(\w\.\w)$#
data> /yandex.ru
No match
data> ^D
t42:~>pcretest 
PCRE version 7.6 2008-01-28

  re> #^/(\w+\.\w+)$#  
data> /yandex.ru
 0: /yandex.ru
 1: yandex.ru
data> ^D


-- 
Игорь Сысоев
http://sysoev.ru





More information about the nginx-ru mailing list