nginx version: 1.12.1
nginx virtual host configuration is as follows:
server{
listen 80;
server_name abc.local;
index index.html index.htm index.php;
root /opt/tool/web;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location /test {
alias /opt/tool/web/cdn/;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
}
location ~ .*\.(js|css)?$ {
expires 12h;
}
access_log off;
}
this configuration file is in the servers directory
nginx.conf through
include servers/*;
introduce.
visit. http://abc.local/test/1.jpg
appears
View nginx error log
[error] 36523-sharp0: *63 open() "/opt/tool/web/test/1.jpg" failed (2: No such file or directory), client: 127.0.0.1, server: abc.local, request: "GET /test/1.jpg HTTP/1.1", host: "abc.local"
I set yes
/ opt/tool/web/cdn/
in the virtual directory test. Why doesn"t it work, and why does he have to visit the root / opt/tool/web directory?