gpt4 book ai didi

nginx - Nginx 配置中静态位置的多个位置

转载 作者:行者123 更新时间:2023-12-05 01:09:30 41 4
gpt4 key购买 nike

我的应用程序将在两个位置提供静态文件,一个是/my/path/project/static,另一个是/my/path/project/jsutils/static。

我很难让网络服务器在两个目录中查找静态内容。这是我在我的应用程序的 nginx 配置文件中的静态位置条目。

    location ^~ /static {
root /my/path/project/static;
alias /my/path/project/jsutils/static;
index index.html index.htm;
}

我收到一条错误消息:“alias”指令是重复的,“root”指令是之前指定的。

我不确定如何让 nginx 在这两个路径中查看静态内容。

预先感谢您的任何帮助。

最佳答案

location ^~ /static {
root /my/path/project/static;
index index.html index.htm;
try_files $uri $uri/ @secondStatic;
}

location @secondStatic {
root /my/path/project/jsutils/static;
}

因此,首先将在/my/path/project/static 中搜索文件,如果在那里找不到,则将触发 secondStatic 位置,将根更改为/my/path/project/jsutils/static。

关于nginx - Nginx 配置中静态位置的多个位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15737440/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com