← ServerPilot Docs

Customizing the Nginx Configuration

Careful! We can't provide support for customizations or for any errors, downtime, or vulnerabilities you introduce through customizations.

Unless you're absolutely sure about what you're doing, you should stop now!
Nginx customizations can break AutoSSL.

Avoid customizing Nginx if you use AutoSSL.
Your server is configured with Nginx as a reverse proxy in front of Apache.

You still can use .htaccess files and mod_rewrite. This is a safe way to change settings.

App (Virtual Host) Customizations

After making any changes, you must restart Nginx by running the following command as root:

sudo service nginx-sp restart

Adding App Configurations

The easiest way to customize an app's Nginx configuration is to add new files in the directory:

/etc/nginx-sp/vhosts.d/APPNAME.d

Note that Nginx loads configuration files from the above directory in alphabetical order. This is important to remember for Nginx directives where order is important, such as the location directive.

Changing Default App Configurations

Every app starts with the following Nginx files created by ServerPilot:

/etc/nginx-sp/vhosts.d/APPNAME.conf
/etc/nginx-sp/vhosts.d/APPNAME.d/main.conf

If you must modify either of these files, you must first rename the file so that ServerPilot won't overwrite your changes.

If you edit APPNAME.conf, rename it to APPNAME.custom.conf.

If you edit main.conf, rename it to main.custom.conf.

Global Customizations

After making any changes, you must restart Nginx by running the following command as root:

sudo service nginx-sp restart

Main Context

If you need to customize the Nginx main context, you can add configuration files in the directory:

/etc/nginx-sp/core.d

Any configurations added in the above directory will be loaded in the Nginx main context.

HTTP Context

If you need to customize the Nginx http context, you can add configuration files in the directory:

/etc/nginx-sp/http.d

Any configurations added in the above directory will be loaded in the Nginx http context.

Event Context

If you need to customize the Nginx events context, you can add configuration files in the directory:

/etc/nginx-sp/events.d

Any configurations added in the above directory will be loaded in the Nginx events context.

Launch your first site in 5 minutes