Welcome! Log In Create A New Profile

Advanced

bugs: try_files & if, add_header

Aleksander
October 16, 2009 09:38AM
Здравствуйте.
Есть пару проблем.

Первая: не совсем работает try_files.

Есть такие файлы:
% find /tmp/test -type f
/tmp/test/hot/file2.txt
/tmp/test/file1.txt

И такой конфиг:

server {
listen 99;
root /tmp/test;
location / {
try_files /hot$uri $uri =404;
}
}

На оба файла отдает нормальный ответ:

HEAD /file1.txt HTTP/1.0

HTTP/1.1 200 OK
Server: nginx/0.8.19
Date: Fri, 16 Oct 2009 13:12:21 GMT
Content-Type: text/plain
Content-Length: 6
Last-Modified: Fri, 16 Oct 2009 12:55:07 GMT
Connection: close
Accept-Ranges: bytes


HEAD /file2.txt HTTP/1.0

HTTP/1.1 200 OK
Server: nginx/0.8.19
Date: Fri, 16 Oct 2009 13:14:06 GMT
Content-Type: text/plain
Content-Length: 7
Last-Modified: Fri, 16 Oct 2009 12:55:24 GMT
Connection: close
Accept-Ranges: bytes


Но как только я добавляю в конфиг проверку с regexp'ом, try_files ломается:

server {
listen 99;
root /tmp/test;
location / {
try_files /hot$uri $uri =404;
if ($uri ~* \.txt$) {

}
}
}

Отдает 404 на второй файл, как будто директивы try_files вообще нет.

HEAD /file1.txt HTTP/1.0

HTTP/1.1 200 OK
Server: nginx/0.8.19
Date: Fri, 16 Oct 2009 13:20:32 GMT
Content-Type: text/plain
Content-Length: 6
Last-Modified: Fri, 16 Oct 2009 12:55:07 GMT
Connection: close
Accept-Ranges: bytes


HEAD /file2.txt HTTP/1.0

HTTP/1.1 404 Not Found
Server: nginx/0.8.19
Date: Fri, 16 Oct 2009 13:20:52 GMT
Content-Type: text/html
Content-Length: 169
Connection: close


И вторая проблема: add_header не работает в контексте server,
а только в location.
Subject Author Posted

bugs: try_files & if, add_header

Aleksander October 16, 2009 09:38AM

Re: bugs: try_files & if, add_header

Igor Sysoev October 16, 2009 09:48AM

Re[2]: bugs: try_files & if, add_header

Aleksander October 16, 2009 10:02AM

Re: bugs: try_files & if, add_header

Maxim Dounin October 16, 2009 10:02AM

Re[2]: bugs: try_files & if, add_header

Aleksander October 16, 2009 10:32AM

Re: bugs: try_files & if, add_header

Maxim Dounin October 16, 2009 12:34PM

Re[2]: bugs: try_files & if, add_header

Aleksander October 16, 2009 01:02PM

Re: bugs: try_files & if, add_header

Denis F. Latypoff October 16, 2009 10:02AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 99
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready