Overview
This article explains where configuration files should be placed on Nginx servers at DreamHost. View the following articles for examples of custom configuration files you could create:
- How to make statistics and permalinks work with WordPress and Nginx
- Password protecting directories with Nginx
- Creating redirects with Nginx
- Blocking IPs with Nginx
Will my .htaccess file function?
Nginx does not support directory-level configurations (such as .htaccess) outside of the primary server configuration file. However, it's still possible to set up local configuration files under your username.
The Nginx configuration directory
This section explains how to create the Nginx configuration directory and how it differs from your website directory.
DreamPress plans do not support changes to the local Nginx configuration directory, meaning configuration adjustments cannot be made directly by the user.
If you need to customize the nginx.conf file, please contact support for assistance.
Where should configuration files be placed?
-
Nginx uses a directory named /nginx under your website username. In this directory, you'll add another directory for your website. This is the only directory you should place any configuration files you want your website to use. For example:
/home/username/nginx/example.comThe /nginx/example.com directories do not exist by default. You must create them manually.
Creating the configuration directory
-
- Log into your server via SSH.
- Navigate to your user's home directory.
- Run the following command:
[server]$ mkdir -p nginx/example.com
The two website directories
-
To clarify, you'll now have two directories your website uses:
The website directory: This is your website directory, where all files are located.
-
/home/username/example.com
The nginx configuration directory: This is where your website's Nginx config files are located.
-
/home/username/nginx/example.com
-
How should configuration files be named?
-
You can name your files anything you like, but they must all use the .conf extension. Nginx will look for files with this extension to insert into the server block of the nginx.conf file.
The nginx.conf file (Dedicated servers only)
The server's config file can only be seen or edited if you're using an admin user on a Dedicated Server.
- Log in to your Dedicated Server via SSH.
- Navigate to the /etc/nginx directory:
[server]$ cd /etc/nginx
- Use sudo to view the directory contents:
[server]$ sudo ls -la
- Enter your password when prompted. You'll see the nginx.conf file listed.
-
Edit the file using sudo:
[server]$ sudo nano nginx.conf
- Save and close the file and return to your shell.