Re: Загадочная проблема с обработкой регулярных выражений

Andrey Rogovsky a.rogovsky at gmail.com
Tue Jul 1 03:54:22 UTC 2014


То есть проблема в edit на конце регулярного выражения?
Я понял, спасибо



2014-07-01 6:16 GMT+03:00 М.А. Мохначевский <tetsio.nainn at gmail.com>:

> location ~ edit$ {
>                 return 444;
>         }
>
> вот и
> 2014/06/30 19:16:45 [debug] 39996#0: *3523 test location: ~ "edit$"
> 2014/06/30 19:16:45 [debug] 39996#0: *3523 using configuration "edit$"
>
>
>
> 01.07.2014 12:42 пользователь "Andrey Rogovsky" <a.rogovsky at gmail.com>
> написал:
>
>> Имею следующий конфиг nginx:
>>
>> -- начало --
>>
>> server {
>> listen  80;
>>   server_name  mydomain.com;
>>   #access_log  /var/log/nginx/mydomain.com.access.log  main;
>>   access_log off;
>>   error_log   /var/log/nginx/mydomain.com.error.log crit;
>>         open_file_cache max=10000 inactive=120s;
>>         open_file_cache_valid 30s;
>>         open_file_cache_min_uses 2;
>>         open_file_cache_errors off;
>>
>> error_page 558 = @post;
>>
>>   location / {
>> limit_req   zone=two  burst=3 nodelay;
>>       proxy_pass http://backend;
>>       proxy_http_version 1.1;
>>       proxy_set_header Connection "";
>>       proxy_redirect off;
>>       #proxy_set_header Host $host;
>>       proxy_set_header Host 'mydomain.com';
>>       proxy_set_header X-Real-IP $remote_addr;
>>       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>>       proxy_set_header UA $uaix;
>>             proxy_set_header MSK $mskix;
>>       proxy_set_header GEOIP_COUNTRY_CODE $geoip_country_code;
>>       proxy_set_header GEOIP_COUNTRY_CODE3 $geoip_country_code3;
>>       proxy_set_header GEOIP_COUNTRY_NAME $geoip_country_name;
>>       proxy_connect_timeout 10;
>>       proxy_send_timeout 10;
>>       proxy_read_timeout 10;
>>
>>     if ($request_method = POST) {
>>     return 558;
>>     }
>>
>>   }
>> if ($uri ~ "^/script_var/(.+\.js)$") {
>>       set $jsname $1;
>> }
>> location  ~* /script_var/.+\.(js)$ {
>>   root /var/www/mydomain.com;
>>   try_files /adv/$geoip_country_code/$jsname  /adv/$jsname  = 404;
>>  }
>>   location = /script.php {
>> return 444;
>>   }
>>         location ~ edit$ {
>>                 return 444;
>>         }
>>   location ~ playlist.php$ {
>>       proxy_pass http://backend;
>>       proxy_redirect off;
>>       proxy_http_version 1.1;
>>       proxy_set_header Connection "";
>>       proxy_set_header Host $host;
>>       proxy_set_header X-Real-IP $remote_addr;
>>       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>>       proxy_set_header UA $uaix;
>>             proxy_set_header MSK $mskix;
>>       proxy_connect_timeout 60;
>>       proxy_send_timeout 60;
>>       proxy_read_timeout 60;
>>   }
>>   location ~ admin.php$ {
>>       allow 91.218.74.202;
>>       allow 213.186.118.138;
>>       allow 94.232.208.220;
>>       allow 176.9.35.227;
>>       allow 83.69.224.215;
>>  #      deny all;
>>       proxy_pass http://backend;
>>       proxy_redirect off;
>>       proxy_http_version 1.1;
>>       proxy_set_header Connection "";
>>       proxy_set_header Host $host;
>>       proxy_set_header X-Real-IP $remote_addr;
>>       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>>  proxy_set_header UA $uaix;
>>             proxy_set_header MSK $mskix;
>>                 proxy_set_header GEOIP_COUNTRY_CODE $geoip_country_code;
>>                 proxy_set_header GEOIP_COUNTRY_CODE3 $geoip_country_code3;
>>                 proxy_set_header GEOIP_COUNTRY_NAME $geoip_country_name;
>>       proxy_connect_timeout 60;
>>       proxy_send_timeout 60;
>>       proxy_read_timeout 60;
>>   }
>>   location ~ ^/cgi-bin/.*\.cgi$ {
>>       proxy_pass http://backend;
>>       proxy_redirect off;
>>   }
>>   location ~ ^/adv/.*$ {
>>       deny all;
>>   }
>>         location ~
>> ^/msqlmdmf/(.+\.(?:gif|jpe?g|png|ico|css|zip|tgz|gz|rar|bz2|tar|js))$ {
>>                 alias /usr/share/phpmyadmin/$1;
>>         }
>>   # Static files location
>>   location ~*
>> ^.+\.(swf|ver|ver|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|tar|wav|bmp|rtf|js)$
>> {
>>       valid_referers none blocked *.mydomain.com mydomain.com;
>>                 if ($invalid_referer) {
>>                        return   403;
>>                 }
>>       root   /var/www/mydomain.com;
>>       expires 10080m;
>>   }
>>   location /nginx_status {
>>       stub_status on;
>>       access_log   off;
>>       allow 91.218.74.202;
>>       allow 213.186.118.138;
>>       allow 94.232.208.220;
>>       allow 212.113.52.4;
>>       deny all;
>>   }
>>
>>
>> location @post
>> {
>> limit_req   zone=two  burst=1;
>> set $limit_rate  128k;
>>       proxy_http_version 1.1;
>>       proxy_set_header Connection "";
>>       proxy_redirect off;
>>       #proxy_set_header Host $host;
>>       proxy_set_header Host 'mydomain.com';
>>       proxy_set_header X-Real-IP $remote_addr;
>>       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>>       proxy_set_header UA $uaix;
>>             proxy_set_header MSK $mskix;
>>       proxy_set_header GEOIP_COUNTRY_CODE $geoip_country_code;
>>       proxy_set_header GEOIP_COUNTRY_CODE3 $geoip_country_code3;
>>       proxy_set_header GEOIP_COUNTRY_NAME $geoip_country_name;
>>       proxy_connect_timeout 10;
>>       proxy_send_timeout 10;
>>       proxy_read_timeout 10;
>> proxy_pass http://backend;
>> #return 444;
>> }
>>
>> }
>>
>> -- конец --
>>
>> В общем все довольно стандартно.
>>
>>
>> При этом запрос к сайту вида http://mydomain.com/actors/Bezrukov
>> обрабатывается нормально:
>>
>> 2014/06/30 19:16:24 [debug] 39999#0: *3009 http script var:
>> "/actors/Bezrukov"
>> 2014/06/30 19:16:24 [debug] 39999#0: *3009 http script regex:
>> "^/script_var/(.+\.js)$"
>> 2014/06/30 19:16:24 [notice] 39999#0: *3009 "^/script_var/(.+\.js)$" does
>> not match "/actors/Bezrukov", client: 188.130.179.10, server:
>> mydomain.com, request: "GET /actors/Bezrukov HTTP
>> /1.1", host: "mydomain.com"
>> 2014/06/30 19:16:24 [debug] 39999#0: *3009 http script if
>> 2014/06/30 19:16:24 [debug] 39999#0: *3009 http script if: false
>> 2014/06/30 19:16:24 [debug] 39999#0: *3009 test location: "/"
>> 2014/06/30 19:16:24 [debug] 39999#0: *3009 test location: "script.php"
>> 2014/06/30 19:16:24 [debug] 39999#0: *3009 test location: "nginx_status"
>> 2014/06/30 19:16:24 [debug] 39999#0: *3009 test location: ~
>> "/script_var/.+\.(js)$"
>> 2014/06/30 19:16:24 [debug] 39999#0: *3009 test location: ~ "edit$"
>> 2014/06/30 19:16:24 [debug] 39999#0: *3009 test location: ~
>> "playlist.php$"
>> 2014/06/30 19:16:24 [debug] 39999#0: *3009 test location: ~ "admin.php$"
>> 2014/06/30 19:16:24 [debug] 39999#0: *3009 test location: ~
>> "^/cgi-bin/.*\.cgi$"
>> 2014/06/30 19:16:24 [debug] 39999#0: *3009 test location: ~ "^/adv/.*$"
>> 2014/06/30 19:16:24 [debug] 39999#0: *3009 test location: ~
>> "^/msqlmdmf/(.+\.(?:gif|jpe?g|png|ico|css|zip|tgz|gz|rar|bz2|tar|js))$"
>> 2014/06/30 19:16:24 [debug] 39999#0: *3009 test location: ~
>> "^.+\.(swf|ver|ver|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|tar|wav|bmp|rtf|js)$"
>> 2014/06/30 19:16:24 [debug] 39999#0: *3009 using configuration "/"
>>
>> А вот с запросом вида http://mydomain.com/actors/Bargess-Meredit
>> происходит вот такой глюк:
>>
>> 2014/06/30 19:16:45 [debug] 39996#0: *3523 http script var:
>> "/actors/Bargess-Meredit"
>> 2014/06/30 19:16:45 [debug] 39996#0: *3523 http script regex:
>> "^/script_var/(.+\.js)$"
>> 2014/06/30 19:16:45 [notice] 39996#0: *3523 "^/script_var/(.+\.js)$" does
>> not match "/actors/Bargess-Meredit", client: 188.130.179.10, server:
>> mydomain.com, request: "GET /actors/Bargess-Meredit HTTP/1.1", host: "
>> mydomain.com"
>> 2014/06/30 19:16:45 [debug] 39996#0: *3523 http script if
>> 2014/06/30 19:16:45 [debug] 39996#0: *3523 http script if: false
>> 2014/06/30 19:16:45 [debug] 39996#0: *3523 test location: "/"
>> 2014/06/30 19:16:45 [debug] 39996#0: *3523 test location: "script.php"
>> 2014/06/30 19:16:45 [debug] 39996#0: *3523 test location: "nginx_status"
>> 2014/06/30 19:16:45 [debug] 39996#0: *3523 test location: ~
>> "/script_var/.+\.(js)$"
>> 2014/06/30 19:16:45 [debug] 39996#0: *3523 test location: ~ "edit$"
>> 2014/06/30 19:16:45 [debug] 39996#0: *3523 using configuration "edit$"
>>
>>
>> Почему /actors/Bargess-Meredit не обрабатывается корневым локейшеном?
>>
>> Причем я пробовал разные версии nginx - глюк повторяется что на текущем,
>> что на свежескаченном с официального сайта. ОС Debian 6.
>>
>>
>> _______________________________________________
>> nginx-ru mailing list
>> nginx-ru at nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx-ru
>>
>
> _______________________________________________
> nginx-ru mailing list
> nginx-ru at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-ru
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-ru/attachments/20140701/a792db52/attachment-0001.html>


Подробная информация о списке рассылки nginx-ru