我在nginx中遇到了一个问题,根指令的内部位置被忽略了。下面是相关设置的代码片段
root /apps/web-ui/latest/;
location /drop-3 {
root /apps/web-ui/drop-3/;
try_files $uri $uri/ /index2.html;
}
location / {
try_files $uri $uri/ /index.html;
}当我访问mysite.com/drop-3/latest时,我得到了404,日志显示nginx试图访问"/apps/web-ui/latest/index2.html“
我尝试在location /drop-3中使用别名和root,但结果仍然相同。
发布于 2019-02-08 20:14:58
除非drop-3的文件是/apps/web-ui/drop-3/drop-3/格式的,否则您的root语句的值是错误的。
文件的路径是通过将root值与请求的URI连接在一起来构造的。详情请参见this document。
try_files语句中的参数是URI。drop-3文件夹中index2.html的正确URI是/drop-3/index2.html。详情请参见this document。
例如:
location /drop-3 {
root /apps/web-ui;
try_files $uri $uri/ /drop-3/index2.html;
}https://stackoverflow.com/questions/54591973
复制相似问题