# Nginx

Nginx (opens new window) web server is an light weight open-source web server.

The Enhance Nginx web server allows for cache exclusion, purge cache, URL rewriting and FastCGI cache to be configured on a per domain basis (including domain aliases.)

Nginx has no .htaccess support.


Due to the lack of .htaccess support the following website tools will not work:

  • Redirects
  • WordPress manger > Restrict admin access

Enhance supports Apache, LiteSpeed, OpenLiteSpeed and Nginx. It is possible to run different web servers on each server in your Enhance cluster. You can also switch between all supported web servers without any configuration changes.

# Switching to Nginx

To switch to a Nginx web server

  1. Select Servers from the left hand menu
  2. Select the server you would like to edit the Application role for
  3. Scroll to Roles section and select the Application tab
  4. Select Settings and when the page loads, select Edit
  5. Select Nginx and follow the instructions on screen to finish

You can expect to see downtime from 30 seconds to 10 minutes, this depends on server load and the number of hosted websites.


If you change the web server on the control panel server and the new web server cannot start, you can use the CLI to switch back. Run:

appcd-cli change-webserver apache

# Caveats

After switching to Nginx, you must:

  • WordPress permalink on existing websites will not work. You will need to add a rewrite under "developer tools" from / to index.php. For new WordPress installations on Nginx this will automatically be created.

# Nginx configuration

The following Nginx configuration tools can be configured on a per domain basis:

FastCGI cache - FastCGI caching will maintain a static cache of your rendered pages to avoid passing the request to PHP.  This will greatly improve performance for your website users when a cached page is served.

Cache exclusion - This will prevent specific paths from being cached.  This is useful for pages which must be dynamic such as shopping carts. An exact path like /wp-admin or a regular expression like ^wp can be excluded.

URL rewriting - This will rewrite paths to a PHP script if the file does not exist.  This is useful for WordPress permalinks functionality and other rewrites which would typically use .htaccess files.

Purge cache - This will delete all currently cached pages from the cache.

To configure per domain Nginx settings

  1. Select Websites from the left hand menu
  2. Select the website you would like to edit the Nginx settings for
  3. Visit Developer tools and scfroll to the Nginx card
  4. Select the domain you would like edit and configure the settings

# Virtual Host Includes

It is not possible to edit the primary nginx.conf. Any changes made to this file will be lost on update. However you can include custom configuration within a virtual host. This is an advanced feature and should be done carefully; incorrect syntax will take down your web server.

To add custom virtual host configuration for a site, log in to your server with SSH as root and edit the file at /var/local/enhance/nginx/vhost_includes/example.com.conf where example.com is the domain for which you want to add the custom configuration. This file will be included at the end of the server block for this domain and will apply to http and https.

# ModSecurity

ModSecurity can be configured via the control panel. For more informaiton see ModSecurity (opens new window).