在设置我的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;
}
答案 0 :(得分:7)
此变量由root
指令设置。你不能在root
指令本身使用它,因为它会导致无限循环。
路径值可以包含变量,
$document_root
和$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
。