Changing Nginx Settings

SpinupWP uses Nginx to serve web requests. The global nginx.conf file is located at /etc/nginx/nginx.conf. You should avoid editing this file unless you are sure you want to make a global change for every site on your server.

When you create a site in SpinupWP, a new Nginx config is created for that site with sensible and secure defaults and is located at:

/etc/nginx/sites-available/{DOMAIN}/{DOMAIN}

You are free to edit this file as you wish. However, you should not edit any lines that have the # Managed by SpinupWP comment as they are required for SpinupWP to work correctly.

Included Directories

There are 4 include statements in the site Nginx config that load all the conf files from specific directories. This makes the Nginx configs easier to manage and debug and is the recommended way of adding customizations to your site’s Nginx config. Instead of editing the site Nginx config directly, you would create a new conf file in one of the following “included” directories:

/etc/nginx/sites-available/{DOMAIN}/before

Included before the server block. For example, global Nginx directive overrides would go here.

/etc/nginx/sites-available/{DOMAIN}/server

Included before any location blocks. For example, custom redirects, custom file handling, cache exclusions, enabling CORS etc. would go here.

/etc/nginx/sites-available/{DOMAIN}/location

Included at the end of the PHP location block. For example, custom fastcgi configuration would go here.

/etc/nginx/sites-available/{DOMAIN}/after

Included after the server block. For example, custom server blocks would go here.

We use this same technique in SpinupWP itself to manage certain configs. For example, when you enable HTTPS for your site in SpinupWP we add a config to the following location with important configuration directives:

/etc/nginx/sites-available/{DOMAIN}/server/https.conf

To edit any Nginx config file you will need to have sudo access which means SSHing to your server as a Sudo user.

To verify that there are no issues with your Nginx configuration you can run:

sudo nginx -t

Remember to reload Nginx when making any changes to your Nginx config files:

sudo service nginx reload