Welcome! Log In Create A New Profile

Advanced

Баг try_files + valid_referers

Андрей Василишин
August 29, 2013 07:48AM
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@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-ru
Subject Author Posted

Баг try_files + valid_referers

Андрей Василишин August 29, 2013 07:48AM

Re: Баг try_files + valid_referers

Maxim Dounin August 29, 2013 08:02AM

Re: Баг try_files + valid_referers

Андрей Василишин August 29, 2013 09:58AM

Re: Баг try_files + valid_referers

Oleksandr V. Typlyns'kyi August 29, 2013 11:04AM

Re: Баг try_files + valid_referers

Maxim Dounin August 29, 2013 11:08AM

Re: Баг try_files + valid_referers

Андрей Василишин August 29, 2013 01:08PM

Re: Баг try_files + valid_referers

denis September 04, 2013 05:40AM

Re: Баг try_files + valid_referers

Валентин Бартенев September 04, 2013 06:58AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 320
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