Nginx configuration file locations

Overview

This article lists the different locations for Nginx configuration files.

This article contains information/examples using root/sudo/admin users. If you require sudo/admin access, you must upgrade to a Dedicated Server.

The nginx.conf file

The main config file can only be seen or edited if you're using an admin user on a Dedicated Server.

  1. Once you've created and admin user, log into your Dedicated Server and navigate to the following directory:
    /etc/nginx/
  2. Use sudo to view the directory contents:
    [server]$ sudo ls -la
  3. Enter your password when prompted.
    You'll see the nginx.conf file listed.
  4. Edit the file using sudo:
    [server]$ sudo nano nginx.conf
    
  5. Save and close the file and return to your shell.

Local configuration files

In the following examples, username would be your Shell user and example.com your website.

Nginx hard codes an include path for every domain, as seen in the following example:

/home/username/nginx/example.com

This /home/username/nginx/example.com directory is the only place you should load any .conf file you want your actual site to use. Additionally, any file ending in .conf is inserted into the server block of the nginx.conf file.

The /nginx/example.com folders do not exist by default. You must create them manually by running the following commands under your username:

[server]$ mkdir -p nginx/example.com

To clarify, you'll now have two directories your domain uses:

  • Your actual web directory (aka document root)
/home/username/example.com
  • Your nginx/example.com directory where ALL config files should be placed
/home/username/nginx/example.com

Examples of .conf files

View the following articles for examples on what a custom .conf file would look like for your site:

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?