将根位置引用为 server {} 块中的变量

sky*_*ler 13 nginx

在我的 nginx server {} 块中,我用路径定义了 root。我以后如何引用此路径?

这就是我想要完成的:

server {
    listen 80;
    root /var/www/foosite;

    ...

    include $root/*.ngaccess;
}
Run Code Online (Sandbox Code Playgroud)

不幸的是,使用 $root 不起作用(因为我还没有定义它)。Nginx 是否提供访问根值的方法?

mgo*_*ven 16

你想要这个document_root变量。