我想在nginx上放一些静态资源,我路由如下配置,但是访问不到?为什么,我的配置方法有问题么?
location / {
root /usr/share/nginx/html;
index index.html;
}
location /test/ {
return 100;
}
location /static/ {
root /usr/share/nginx/static;
index index.html;
}
可以正常访问域名并出现首页,但是如果我在域名后面加了/static 之后会404,服务器上这些文件都是有的?
是我location配置方法错误还是其他原因 如何排查?
/static
,填写 path 时也要写/static
。要不就都写/static/
,需要保持一致(这也许是 alias 才需要注意的,使用 root 应该没有这个限制,我没有去验证,只是道听途说)。