Nginx configuration file locations


If you have changed your web server to Nginx, you will notice certain configuration files (such as .htaccess) no longer function. This is because Nginx does not support directory-level configurations outside of the primary server configuration file. However, it's still possible to set up local configuration files under your username for customizations like a redirect.

This article lists the different configuration file locations for Nginx at DreamHost.

Local configuration files

Nginx enables an /nginx directory under your website username. It is located in the following directory:

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


This directory is the only place you should load any .conf file you want your website to use. Additionally, any file ending in .conf is inserted into the server block of the nginx.conf file.

Creating the configuration directory

The /nginx/ directories do not exist by default. You must create them manually by running the following command under your username:

  1. Log into your server via SSH.
  2. Navigate to your user's home directory.
  3. Run the following command:
    [server]$ mkdir -p nginx/

You can now add your custom configuration files ending in .conf to this directory for the website

The two Nginx directories

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

Your website directory

This is your website directory where all files are located.


Your nginx configuration directory

This is where all Nginx config files are located.


The nginx.conf file (Dedicated servers only)

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

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

  1. Log into your Dedicated Server server via SSH.
  2. Navigate to the /etc/nginx directory:
    [server]$ cd /etc/nginx
  3. Use sudo to view the directory contents:
    [server]$ sudo ls -la
  4. Enter your password when prompted.
    You'll see the nginx.conf file listed.
  5. Edit the file using sudo:
    [server]$ sudo nano nginx.conf
  6. Save and close the file and return to your shell.

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?