Nginx: root path relative to conf file

Is it possible to specify root path relative to the containing conf file?

Short answer: No.

Long answer: Nginx, by default, only knows about the path such as --prefix and --conf-path that are set at the compile time (ref: https://nginx.org/en/docs/configure.html). We can find various paths used by Nginx by running the command nginx -V (it’s capital “V”). So, --conf-path is where the main nginx.conf file resides and that path is used for any relative paths.

According to the official documentation (https://nginx.org/r/root), a root directive can contain other variables, though.

Thanks for @cyker for clarifying after 5 years of posting the initial answer!

Leave a Comment