nginx include 语句后面如何使用变量

include $document_root/aaa.txt;

会报错误
open() "/etc/nginx/$document_root/aaa.txt" failed (2: No such file or directory) in /etc/nginx/nginx.conf:xxx

include后面的变量并未被解析

阅读 6.5k
2 个回答

include的时候还没变量吧,变量是很后面才有的。

http://nginx.org/en/docs/ngx_core_module.html#include

Syntax: include file | mask;
Default: —
Context: any
Includes another file, or files matching the specified mask, into configuration. Included files should consist of syntactically correct directives and blocks.

Usage example:

include mime.types;
include vhosts/*.conf;
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题