要包含的 nginx 相对路径

Ale*_*erg 14 configuration nginx

在 nginx conf 文件中,有什么方法可以指定include相对于当前 conf 文件的另一个 conf 文件?

我想写:

server {
  listen       80;
  server_name  localhost;

  include "../apis/basic.conf";

...
} 
Run Code Online (Sandbox Code Playgroud)

Mar*_*erg 6

include指令的 Nginx 文档没有记录如何处理相对路径(从 1.9.15 版开始)。我对 C 代码的阅读是路径必须是绝对的或相对于前缀路径的,正如 Alexey Ten 在评论中提供的那样。

这是源代码相关链接


小智 5

与 Alexy Ten 在上面评论的类似,将使用默认前缀。但是根据这个 StackOverflow 帖子:https ://stackoverflow.com/a/25486871/1684819可以提供 -p 选项来声明所有相对路径将被引用到的位置,而不是默认的编译路径。