Adjusting nginx Settings for Virtual Hosts

By default, the Apache web server is working in conjunction with nginx. The benefits are that web pages load faster and server resources are saved. To learn how Apache and nginx collaborate by default, see Apache with nginx.

For any website, you can change the default way of Apache and nginx collaboration. More exactly, you can specify which web content (static or dynamic) should be processed by each of the servers. This can help optimize the performance of highly loaded web applications that have a lot of dynamic content (PHP files) or a lot of static content. The corresponding settings are available in the Customer Panel on the Websites & Domains > <domain_name> > Apache & nginx Settings page.

Note: Nginx-related settings are available only if nginx is turned on.

The diagrams below show all the possible configurations and provide comments on pros and cons of each configuration.

Processing Static Content

The following table shows how Plesk will handle the request for a 2KB GIF image file depending on the nginx configuration.

 

header

 

Smart static files processing is turned on

default

It is the optimal configuration in terms of performance and reliability.

The request is passed to Apache which returns only a file location. The file is located and delivered by nginx.

Smart static files processing is turned off

transparent

nginx passes requests and responses without modification which allows using the mode for troubleshooting nginx related issues.

The file is sent twice: from Apache to nginx and from nginx to client. This may slightly reduce the performance especially when delivering large files.

 

The GIF file extension is included into Serve static files directly by nginx

static_by_nginx

This mode improves performance of delivering static files.

Note that as requests never reach Apache, they do not pass through Apache handlers. This means that, for example, rewrite rules or .htaccess directives will not be applied.

Processing Dynamic Content

The following table shows how Plesk will handle the request for a PHP file depending on the nginx configuration.

 

header

 

Process PHP by nginx is turned off

It is the optimal configuration in terms of performance and reliability.

The request is passed to Apache which executes the file and returns the result.

Depending on the site’s hosting settings, Apache uses one of the following handlers: FastCGI, CGI, or the Apache module. You can also choose the PHP version individually for each site.

Process PHP by nginx is turned on

php_nginx

nginx itself executes the file using the PHP-FPM handler. The PHP-FPM handler offers enhanced FastCGI capabilities, which may improve performance of web apps, especially those with many users.

Note that as requests never reach Apache, they do not pass through Apache handlers. This means that some web apps may not operate as expected. Apache .htaccess directives and rewrite rules will not be applied as well.

 

Important: To make the option Process PHP by nginx available, you should install PHP-FPM support for nginx. For details on installing PHP-FPM support, refer to the section PHP Handlers.

Setting Up Additional nginx Directives

To add custom nginx directives for a website, use the Additional nginx directives field. When editing the field, use the syntax as in nginx.conf. For example, if you want to pack all the proxied requests with gzip, add the line:

gzip_proxied any;

Note that your customers cannot view and edit the Additional nginx directives field.

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Automated website copying in Plesk 12

Log in to the Plesk Control Panel Go to the Websites & Domains and click the name of the...

How to set up custom nameservers in Plesk

Once your domain has been created in Plesk you will need to configure the DNS settings for your...

Logging In to Plesk

To log in to Plesk, open your web browser and open the following address:...

Plesk Editions

Starting from Plesk 12, you can choose from four Plesk editions that have features mostly used by...

Plesk Users

Plesk is a web hosting control panel that targets three user groups: Administrators. These...