nginx代理静态目录后,无法访问静态目录下的多级目录的资源。
比如:http://127.0.0.1:80/statics/applet/test.png
可以正常访问,
比如:http://127.0.0.1:80/statics/applet/user/user.png
路径末尾会自动加上 “/”, 同时显示404,错误如下:
环境使用docker + nginx;
nginx版本:1.22.0
尝试一:访问user.png => 404
location / {
root /app/docker/statics/web;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
location /applet {
root /app/docker/statics;
index index.html;
}
尝试二:访问user.png => 404
location / {
root /app/docker/statics/web;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
location /applet {
alias /app/docker/statics/applet;
}
请问图片位于静态目录的不同路径下,nginx是如何配置的呢?
可以尝试使用正则表达式来处理静态请求