Adjusting nginx Settings for Virtual Hosts¶
By default, the Apache web server works 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 method of Apache and nginx collaboration. More exactly, you can:
- Specify whether nginx must work as a proxy for Apache or as an independent server for handling all HTTP requests to websites.
- Specify which type of web content (static or dynamic) must be processed by each of the servers if you use nginx as a proxy server.
Such settings 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 UI options are available in the Customer Panel in Websites & Domains > <domain_name> > Apache & nginx Settings.
nginx-related settings are available only if nginx is turned on.
The diagrams below show all the possible configurations for Apache working in conjunction with nginx, and provide comments on pros and cons of each configuration. Note that if you use nginx alone, no requests can reach Apache.
Processing Static Content¶
The following table shows how Plesk handles the request for a 2KB GIF image file depending on the nginx configuration.
Processing Dynamic Content¶
The following table shows how Plesk will handle a request for a PHP file depending on the nginx configuration.
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:
Note that your customers cannot view and edit the Additional nginx directives field.