search

Home  >  Q&A  >  body text

How to use variables after nginx include statement

like

include $document_root/aaa.txt;

An error will be reported
open() "/etc/nginx/$document_root/aaa.txt" failed (2: No such file or directory) in /etc/nginx/nginx.conf:xxx

The variables after include are not parsed

迷茫迷茫2842 days ago715

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-05-16 17:22:46

    There were no variables when including it. Variables only appeared very later.

    reply
    0
  • PHPz

    PHPz2017-05-16 17:22:46

    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;

    reply
    0
  • Cancelreply