Anonymous User
October 23, 2022 01:22PM
Здравствуйте.

Сейчас столкнулся с непонятной ошибкой.

Тестовый пример:
```
root /var/www;

location / {
try_files $uri =404;
}

location /test/ {
try_files $uri =404;
alias /var/test/;
}
```

Проверяю доступность тестового файла через curl:
```
curl --head -k https://example.com/test/example.txt
HTTP/2 200
...
```

Файл доступен. Лог отладки:
```
...
*302 test location: "/"
*302 test location: "test/"
*302 using configuration "/test/"
...
*302 http script var: "/test/example.txt"
*302 trying to use file: "example.txt" "/var/test/example.txt"
*302 try file uri: "/test/example.txt"
...
*302 http filename: "/var/test/example.txt"
...
*302 http2 output header: ":status: 200"
...
```

Меняю location `test` на такой вариант:
```
location ~ ^/(test|custom)/ {
try_files $uri =404;
alias /var/test/;
}
```

Теперь файл не доступен. По идее должно работать... Лог отладки:
```
...
*303 test location: "/"
*303 test location: ~ "^/(test|custom)/"
*303 using configuration "^/(test|custom)/"
...
*303 http script copy: "/var/test/"
*303 http script var: "/test/example.txt"
*303 trying to use file: "/test/example.txt" "/var/test//test/example.txt"
*303 trying to use file: "=404" "/var/test/=404"
*303 http finalize request: 404, "/test/example.txt?" a:1, c:1
*303 http special response: 404, "/test/example.txt?"
...
*303 http2 output header: ":status: 404"
...
```

Так и должно работать?
Только вот если убрать параметр `alias /var/test/;`, то `location /test/` и `location ~ ^/(test|custom)/` работают одинаково.


--
С уважением,
Izorkin mailto:izorkin@gmail.com

_______________________________________________
nginx-ru mailing list -- nginx-ru@nginx.org
To unsubscribe send an email to nginx-ru-leave@nginx.org
Subject Author Posted

Работа location с алиасом

Anonymous User October 23, 2022 01:22PM

Re: Работа location с алиасом

Maxim Dounin October 23, 2022 04:38PM

Re[2]: Работа location с алиасом

Татьяна Орлова via nginx-ru October 23, 2022 04:52PM

Re: Работа location с алиасом

Anonymous User October 24, 2022 02:48AM

Re: Работа location с алиасом

Maxim Dounin October 24, 2022 11:50AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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