Score:0

nginx equivalant of apache's IncludeOptional

bg flag

Both Apache & nginx have a way to “include the contents of this file in the configuration”, (Include & include resp.). Both will cause the configuration to be invalid if the provided filename does not exist.

But Apache also has IncludeOptional, which fuctions the same, except it will not cause an error in the configuration if the file does not exist. (It will cause an error if the file exists and is not a valid apache configuration file).

Does nginx have such “include this file if it exists, but don't error if it doesn't” functionality?

Score:1
jp flag

As the Core functionality Directives list is exhaustive, this obviously does not exist as a distinct directive. However, the mask variant does not require any files to actually match.

  • 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;

E.g., the default nginx.conf from Ubuntu/Debian comes with an example; the /etc/nginx/conf.d/ directory is empty, but this does not raise any errors:

include /etc/nginx/conf.d/*.conf;
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.