I see in main configuration file relative path which should be included. Like

include file.conf;

How it relative path would interpreted to absolute? According to the directory where main configuration file is or there's any another declared "main" path and such way the result path would be "main"/file.conf?

  • for debian the relative starts in /etc/nginx
    – djdomi
    Commented Apr 11 at 9:42
  • 1
    It's a compile time option. You can use nginx -V to see all the compile time options used to generate your nginx binary. I think the one you are looking for is --prefix. Commented Apr 11 at 14:27
  • @RichardSmith No, I think it's only --conf-path=/etc/nginx/nginx.conf cause included file inside there. dirname $(nginx -V 2>&1 | grep -o '\-\-conf-path=\(.*conf\)' | cut -d '=' -f2)
    – palmasd1
    Commented Apr 11 at 15:53
  • my comment is moderating the above comments: there are complie time options which determine where nginx.conf is located, it is not only in /etc/nginx, particularly with other distro's and other pure Nginx (not forked) solutions such as OpenResty which places nginx.conf in /usr/opt/openresty/nginx/conf/nginx.conf...
    – bellasys
    Commented May 2 at 7:48

1 Answer 1


simple answer is that file.conf is relative to nginx.conf file from which it is called, such that if nginx.conf is located at /etc/nginx/nginx.conf then /etc/nginx/file.conf needs to exist to be included.

Please note that for Nginx there are many possible locations for the nginx.conf file itself depending on the Platform, Linux Distro, compile-time options when compiled from Source, etc.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .