Всем привет.
Не могу понять причину.
Если контекст такого вида, то 403 Forbidden
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @php;
}
}
Есть убрать $uri/, то сайт работает, но nginx ругается
nginx: [emerg] "try_files" directive is duplicate in /etc/nginx/vhosts/012447/my-site.ru.conf:17 nginx: configuration file /etc/nginx/nginx.conf test failed
Я понимаю, что "try_files" directive is duplicate
, но почему тогда с $uri/
такой ругани нет?
Сам конфиг
server {
server_name my-site.ru www.my-site.ru;
charset UTF-8;
index index.php, index.html;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/my-site.ru/*.conf;
access_log /home/httpd-logs/my-site.ru.access.log;
error_log /home/httpd-logs/my-site.ru.error.log notice;
ssi on;
set $root_path /home/012447/data/www/my-site.ru;
root $root_path;
listen 11.22.33.44:80;
include /etc/nginx/vhosts-resources/012447/*.conf;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @php;
}
}
return 301 https://$host:443$request_uri;
location ~* /wp-includes/.*.php$ {
deny all;
access_log off;
log_not_found off;
}
location ~* /wp-content/.*.php$ {
deny all;
access_log off;
log_not_found off;
}
location ~* /(?:uploads|files)/.*.php$ {
deny all;
access_log off;
log_not_found off;
}
location ~* /themes/.*.php$ {
deny all;
access_log off;
log_not_found off;
}
location ~* /plugins/.*.php$ {
deny all;
access_log off;
log_not_found off;
}
location = /xmlrpc.php {
deny all;
access_log off;
log_not_found off;
}
location ~* wp-config.php {
deny all;
}
location ~ ^/\.user\.ini {
deny all;
}
# }
location ~* ^/wp-content/uploads/.+\.php{
deny all;
}
location ~* .ini$ {
deny all;
}
location ~ \.user\.ini$ {
deny all;
}
location @php {
fastcgi_index index.php;
fastcgi_pass unix:/var/www/php-fpm/012447.sock;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@my-site.ru";
fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
try_files $uri =404;
include fastcgi_params;
}
# location ~* ^/wp-json/ {
# deny all;
}
server {
server_name my-site.ru www.my-site.ru;
ssl_certificate "/var/www/httpd-cert/012447/my-site.ru_le2.crtca";
ssl_certificate_key "/var/www/httpd-cert/012447/my-site.ru_le2.key";
ssl_ciphers E!RC4;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
charset UTF-8;
index index.php, index.html;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/my-site.ru/*.conf;
access_log /home/httpd-logs/my-site.ru.access.log;
error_log /home/httpd-logs/my-site.ru.error.log notice;
ssi on;
set $root_path /home/012447/data/www/my-site.ru;
root $root_path;
include /etc/nginx/vhosts-resources/012447/*.conf;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @php;
}
}
location ~* /wp-includes/.*.php$ {
deny all;
access_log off;
log_not_found off;
}
location ~* /wp-content/.*.php$ {
deny all;
access_log off;
log_not_found off;
}
location ~* /(?:uploads|files)/.*.php$ {
deny all;
access_log off;
log_not_found off;
}
location ~* /themes/.*.php$ {
deny all;
access_log off;
log_not_found off;
}
location ~* /plugins/.*.php$ {
deny all;
access_log off;
log_not_found off;
}
location = /xmlrpc.php {
deny all;
access_log off;
log_not_found off;
}
location ~* wp-config.php {
deny all;
}
location ~ ^/\.user\.ini {
deny all;
}
# }
location ~* ^/wp-content/uploads/.+\.php{
deny all;
}
location ~* .ini$ {
deny all;
}
location ~ \.user\.ini$ {
deny all;
}
location @php {
fastcgi_index index.php;
fastcgi_pass unix:/var/www/php-fpm/012447.sock;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@my-site.ru";
fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
try_files $uri =404;
include fastcgi_params;
}
listen 11.22.33.44:443 ssl;
# location ~* ^/wp-json/ {
# deny all;
}