gpt4 book ai didi

nginx - $document_root 变量不能在 "root"指令中使用

转载 作者:行者123 更新时间:2023-12-01 09:52:58 50 4
gpt4 key购买 nike

在设置我的 nginx 配置时,我遇到了这个问题。有没有人知道为什么会发生这种情况?

root /folder/my_root;

index index.php index.html index.htm;
error_page 404 /404.html;
location = /404.html{
root $document_root/error_pages; //FAILS HERE with the error in the title
internal;
}

最佳答案

此变量由 root 设置指示。您不能在 root 中使用它指令本身,因为它会导致无限循环。

http://nginx.org/r/root

The path value can contain variables, except $document_root and $realpath_root.



请改用您自己的变量。
set $my_root folder/my_root;
root /$my_root;
...

location = /404.html {
root /$my_root/error_pages;
}

并且不要尝试将前导斜杠放入变量中。 root $var会找 $var在一些默认目录中,如 /usr/local/nginx/etc/nginx .

关于nginx - $document_root 变量不能在 "root"指令中使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34221381/

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