Welcome! Log In Create A New Profile

Advanced

Не корректно работает root в nginx

MihaKot
July 31, 2020 07:16AM
есть конфигурация nginx

server {
listen 80;
server_name client.test.domain;

charset utf-8;

root /var/www/_test.domain/client/;
index index.php index.html;

client_max_body_size 0;

location / {
#root /var/www/_test.domain/client/;
}
location /html {
#root /var/www/_test.domain/;
alias /var/www/_test.domain/html;
}

location ~ \.php$ {
fastcgi_pass unix:/var/run/php-www.sock;
#fastcgi_pass 127.0.0.1.:9000;
fastcgi_index index.php;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
include fastcgi_params;
fastcgi_param HTTPS on;
fastcgi_param SCRIPT_FILENAME
/var/www/_test.domain/client$fastcgi_script_name;
#fastcgi_param PHP_ADMIN_VALUE
"open_basedir=/var/www:/tmp:/var/lib/sessions:/var/www/tmp:/var/www/log";
#include /etc/nginx/fastcgi_params;
}


location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
return 403;
error_page 403 /403_error.html;
}

# caching of files
location ~* \.(ico|pdf|flv)$ {
expires 1y;
}
location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ {
expires 14d;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}}

При такой конфигурации скрипты работают, при запросе
client.test.domain/html/css/style.css выдает 404 Not found

в логе nginx видно что файл ищет
"/var/www/_test.domain/client/html/css/style.css"

если же сделать так

#root /var/www/_test.domain/client/;
index index.php index.html;

client_max_body_size 0;

location / {
root /var/www/_test.domain/client/;
}
location /html {
#root /var/www/_test.domain/;
alias /var/www/_test.domain/html;
}

то он пытается найти файл в "/etc/nginx/html/html/css/style.css"

замена на root тоже игнорируется.


location /html { root /var/www/_test.domain/; #alias /var/www/_test.
domain/html; }

пытается найти файл по "/var/www/_test.domain/client/html/css/style.css"


я уже сломал весь мозг. Потому как в документации сказано что root и alias
в location должно работать.

но вот у меня не работает.(((
_______________________________________________
nginx-ru mailing list
nginx-ru@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-ru
Subject Author Posted

Не корректно работает root в nginx

MihaKot July 31, 2020 07:16AM

Re: Не корректно работает root в nginx

Evgeniy Berdnikov July 31, 2020 08:06AM

Re: Не корректно работает root в nginx

Maxim Dounin July 31, 2020 08:12AM

Re: Не корректно работает root в nginx

MihaKot July 31, 2020 08:38AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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