ПРОЕКТЫ 


  АРХИВ 


Apache-Talk @lexa.ru 

Inet-Admins @info.east.ru 

Filmscanners @halftone.co.uk 

Security-alerts @yandex-team.ru 

nginx-ru @sysoev.ru 


  СТАТЬИ 


  ПЕРСОНАЛЬНОЕ 


  ПРОГРАММЫ 



ПИШИТЕ
ПИСЬМА












     АРХИВ :: nginx-ru
Nginx-ru mailing list archive (nginx-ru@sysoev.ru)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Баг try_files + valid_referers


  • To: nginx-ru <nginx-ru@xxxxxxxxx>
  • Subject: Баг try_files + valid_referers
  • From: Андрей Василишин <a.vasilishin@xxxxxx>
  • Date: Thu, 29 Aug 2013 14:47:01 +0300
  • Authentication-results: mail0.kpi.ua; auth=pass (auth_dovecot_plain) smtp.mail=andron@xxxxxx

        location / {
            index  index.php index.htm index.html;
            root   /var/www/site.com;
            try_files $uri
                $uri/
                /index.php?q=$uri&$args
                @backend;
rewrite "^/([^\/]+/[^\/]+)/((s[\d]+)?(e[\d]+){1}(\-[\d]+)*)$" /$1.html?serie=$2;
                rewrite ([^\/]+/[^\/]+.html)/$ /$1 permanent;
                rewrite (tag/[^\/]+)/$ /$1 permanent;
valid_referers none server_names ~(yandex|google|yahoo|bing|facebook|fbcdn|mail.ru|rambler|nigma|vk.com);
                if ($invalid_referer) {
access_log /var/log/nginx/site.com.invalid.log main;
                }
                if ($a) {
access_log /var/log/nginx/a.site.com.access.log main;
                }

        }


Почему-тоЮ, если приходит запрос с реферером, которого нет в valid_referers, try_files почему-то проверяет только $uri и потом возвращает сразу 404:

2013/08/29 11:06:34 [debug] 7188#0: *1851357643 http script var
2013/08/29 11:06:34 [debug] 7188#0: *1851357643 http script var: "1"
2013/08/29 11:06:34 [debug] 7188#0: *1851357643 http script if
2013/08/29 11:06:34 [debug] 7188#0: *1851357643 http script var
2013/08/29 11:06:34 [debug] 7188#0: *1851357643 http geo started: 176.104.57.123
2013/08/29 11:06:34 [debug] 7188#0: *1851357643 http geo:
2013/08/29 11:06:34 [debug] 7188#0: *1851357643 http script var: ""
2013/08/29 11:06:34 [debug] 7188#0: *1851357643 http script if
2013/08/29 11:06:34 [debug] 7188#0: *1851357643 http script if: false
2013/08/29 11:06:34 [debug] 7188#0: *1851357643 post rewrite phase: 4
2013/08/29 11:06:34 [debug] 7188#0: *1851357643 generic phase: 5
2013/08/29 11:06:34 [debug] 7188#0: *1851357643 generic phase: 6
2013/08/29 11:06:34 [debug] 7188#0: *1851357643 generic phase: 7
2013/08/29 11:06:34 [debug] 7188#0: *1851357643 access phase: 8
2013/08/29 11:06:34 [debug] 7188#0: *1851357643 access phase: 9
2013/08/29 11:06:34 [debug] 7188#0: *1851357643 post access phase: 10

2013/08/29 11:06:34 [debug] 7188#0: *1851357643 try files phase: 11
2013/08/29 11:06:34 [debug] 7188#0: *1851357643 content phase: 12
2013/08/29 11:06:34 [debug] 7188#0: *1851357643 content phase: 13
2013/08/29 11:06:34 [debug] 7188#0: *1851357643 content phase: 14
2013/08/29 11:06:34 [debug] 7188#0: *1851357643 http filename: "/var/www/site.com/series/univer-novaya-obschaga-serial.html" 2013/08/29 11:06:34 [debug] 7188#0: *1851357643 add cleanup: 00000000019C3E58 2013/08/29 11:06:34 [error] 7188#0: *1851357643 open() "/var/www/site.com/series/univer-novaya-obschaga-serial.html" failed (2: No such file or directory), client: 176.104.57.123, server: site.com, request: "GET /series/univer-novaya-obschaga-serial.html HTTP/1.1", host: "site.com", referrer: "http://www.top-page.ru/ya/?q=%D0%BD%D0%BE%D0%B2%D0%B0%D1%8F+%D0%BE%D0%B1%D1%89%D0%B0%D0%B3%D0%B0+%D0%BD%D0%BE%D0%B2%D1%8B%D0%B5+%D1%81%D0%B5%D1%80%D0%B8%D0%B8+%D1%81%D0%BC%D0%BE%D1%82%D1%80%D0%B5%D1%82%D1%8C+%D0%BE%D0%BD%D0%BB%D0%B0%D0%B9%D0%BD"; 2013/08/29 11:06:34 [debug] 7188#0: *1851357643 http finalize request: 404, "/series/univer-novaya-obschaga-serial.html?" a:1, c:1 2013/08/29 11:06:34 [debug] 7188#0: *1851357643 http special response: 404, "/series/univer-novaya-obschaga-serial.html?" 2013/08/29 11:06:34 [debug] 7188#0: *1851357643 internal redirect: "/errors/404.html?"


Если закомментировать строки:
valid_referers none server_names ~(yandex|google|yahoo|bing|facebook|fbcdn|mail.ru|rambler|nigma|vk.com);
                if ($invalid_referer) {
access_log /var/log/nginx/site.com.invalid.log main;

 все идет как надо, то есть доходит до /index.php?q=$uri&$args

# nginx -V
nginx version: nginx/1.2.4
configure arguments: --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-file-aio --with-http_flv_module --with-http_geoip_module --with-http_mp4_module --with-http_realip_module --with-http_secure_link_module --with-http_stub_status_module --without-http_scgi_module --without-http_split_clients_module --without-http_ssi_module --without-http_userid_module --without-http_uwsgi_module

Ну, и чтоб два раза не вставать: какой альтернативный способ писать отдельный лог для invalid_referer?

_______________________________________________
nginx-ru mailing list
nginx-ru@xxxxxxxxx
http://mailman.nginx.org/mailman/listinfo/nginx-ru


 




Copyright © Lexa Software, 1996-2009.