Does "include" use the "configuration prefix" or the "path prefix"?

I’ve read the documentation and it implies the “path prefix” would be
used for the “include” directive.

Example: “include mime.types”

However, in practice, the “configuration prefix” is always used even if
the file is found within the “path prefix”.
Is this the correct behaviour?

Here are sample values:

nginx path prefix:          "/tmp/app"
nginx binary file:          "/tmp/app/progs/nginx/sbin/nginx"
nginx configuration prefix: "/tmp/app/progs"
nginx configuration file:   "/tmp/app/progs/nginx.conf"

(I used 1.8.1 and 1.9.14.)

  • diego

Hello!

On Mon, Apr 11, 2016 at 06:52:25PM +0000, [email protected] wrote:

I’ve read the documentation and it implies the “path prefix”
would be used for the “include” directive.

Example: “include mime.types”

However, in practice, the “configuration prefix” is always used
even if the file is found within the “path prefix”.
Is this the correct behaviour?

Yes, this is correct behaviour. Configuration-specific paths like
in the “include” directive are resolved relative to the conf prefix,
that is, relative to the directory where nginx.conf file resides.


Maxim D.
http://nginx.org/

THank you very much for confirmation.
Is this documented anywhere?

I looked at various places:
http://nginx.org/en/docs/ngx_core_module.html#include
http://nginx.org/en/docs/switches.html

and I could not find it. (I also tried reading the C source,
https://github.com/nginx/nginx/blob/master/src/core/ngx_conf_file.cbut
got lost due to my lack of C experience.)

  • diego

On Monday, April 11, 2016 2:43 PM, Maxim D. [email protected]
wrote:
Hello!

Yes, this is correct behaviour. Configuration-specific paths like
in the “include” directive are resolved relative to the conf prefix,
that is, relative to the directory where nginx.conf file resides.


Maxim D.
http://nginx.org/


nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

Hello!

On Mon, Apr 11, 2016 at 07:54:58PM +0000, [email protected] wrote:

THank you very much for confirmation.
Is this documented anywhere?

I don’t think it’s explicitly documented anywhere except in
CHANGES for 0.6.7 (http://nginx.org/en/CHANGES):

*) Change: now the paths specified in the "include",
   "auth_basic_user_file", "perl_modules", "ssl_certificate",
   "ssl_certificate_key", and "ssl_client_certificate" directives 

are
relative to directory of nginx configuration file nginx.conf, but
not
to nginx prefix directory.

Basically, there are two types of paths in nginx configuration:

  • configuration-specific paths (include, SSL certs/keys,
    auth_basic_user_file - that is, things that naturally a part of
    configuration), resolved relative to nginx.conf file;

  • all other paths, resolved from prefix.

This should be documented somewhere, and we already have a ticket
for a related question, #781 (Documentation not clear on auth_basic_user_file) – nginx.


Maxim D.
http://nginx.org/

I found some bits: prefix is explained on the command-line parameters
docs
page http://nginx.org/en/docs/switches.html and, in a little more
vebose
fashion, in an nginx.com tutorial
https://www.nginx.com/resources/wiki/start/topics/tutorials/installoptions/,
probably thanks to Rick Nelson.

Life’s lesson: never consider anything as obvious for everyone… Easy
to
say, hard to apply.

B. R.