How to enable Nginx as reverse proxy in Plesk 12

 
Tested Environment:  Centos 7

Plesk Version: 12

 
Overview:  Apache with Nginx
Nginx, a supplementary high-performance web server which is typically used as a reverse proxy server.
This web server was specifically designed for delivering large amounts of static content (such as images, video, css, xml, and so on).
As opposed to Apache, nginx is much more efficient when it comes to handling a large number of concurrent connections.
Another advantage of this web server compared with Apache is that nginx has a significantly smaller memory footprint per client connection.

To leverage all the benefits of nginx, Plesk configures it as a reverse proxy server that stands between the Internet and Apache.
This means that nginx becomes a frontend web server that processes all incoming requests from site visitors. The requests are sent to Apache which, in turn,
distinguishes requests for static and dynamic content. If a request is for a static file (such as jpg, css, html, and so on),
Apache passes the request through all registered handlers (applies .htaccess directory-level configuration, rewrites a URL, and so on)
and returns to nginx a response which contains only the location of the requested file on the file system. nginx locates the file and sends it to the client.
If the request is for a dynamic file (such as a PHP script), Apache executes the file and sends the response to nginx, which delivers it to the client.

Please see screenshot URL for the diagram: http://prntscr.com/69jir2

Such a combination of nginx and Apache gives the following advantages:

  • The maximum number of concurrent connections to a website increases.
  • The consumption of server CPU and memory resources decreases.
    The maximum effect will be achieved for websites with a large amount of static content (such as photo galleries, video streaming sites, and so on).
  • The efficiency of serving visitors who have a slow connection speed (GPRS, EDGE, 3G, and so on) improves.
    For example, a client with a 10 KB/s connection requests a PHP script, which generates a 100 KB response. If there is no nginx on the server, the response is delivered by Apache. During the 10 seconds required to deliver the response, Apache and PHP continue to consume full system resources for this open connection. If nginx is installed, Apache forwards the response to nginx (the nginx-to-Apache connection is very fast as both of them are located on the same server) and releases system resources. As nginx has a smaller memory footprint, the overall load on the system decreases. If you have a large number of such slow connections, use of nginx will significantly improve website performance.

Source: http://download1.parallels.com/Plesk/Doc/en-US/online/plesk-administrator-guide/

Installing Nginx:

1. Install via Tool & Settings >Updates & Upgrade> Add Components

          Nginx reverse proxy support (install)

 2. Once the component is added, you should run the Reverse Proxy Server (nginx) service in Tools & Settings > Services Management.

 

3. To check the current Nginx component status via CLI:

 /usr/local/psa/admin/sbin/nginxmng –s

Ex. [root@localhost ~]# /usr/local/psa/admin/sbin/nginxmng -s

Enabled

 
4. Verify if sevice is running:

/etc/init.d/nginx status – Centos 6

nginx is running.

systemctl status nginx.service – Centos 7

 
5.Tuning Nginx settings for your Domains’ website (virtual host):

In any  of your website , you can specify which web content (static or dynamic) that should be processed by either Apache or Nginx. This can help tune  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 on this plesk panel section:

 Websites & Domains > <domain_name> > Web Server Settings page.

Nginx Settings:

Smart static files processing :

If turned off, Apache will process all requests for static files. nginx will only pass requests and responses without modification. Turn off this option only for troubleshooting.

 
Serve static files directly by nginx :

If enabled, requests for these files will be handled by nginx and never reach Apache.

---

ac3 avi bmp bz2 css cue dat doc docx dts exe flv gif gz htm html ico img iso jpeg jpg js mkv mp3 mp4 mpeg

 mpg ogg pdf png ppt pptx qt rar rm swf tar tgz txt wav xls xlsx zip

---

 
Caution: Apache rewrite rules will not be applied

Process PHP by nginx:

PHP files (.php) will be handled by nginx and PHP-FPM. If turned off, PHP files will be processed by Apache.

References:

http://kb.sp.parallels.com/en/119595

http://download1.parallels.com/Plesk/Doc/en-US/online/plesk-administrator-guide/

  • 3 Uživatelům pomohlo
Byla tato odpověď nápomocná?

Související články

Setup DNS in Plesk

Please note that we do not offer DNS hosting. To get your site hosted on the VPS, you can either:...

How to create a catch-all email account

From Plesk control panel, select your domain name. Then click on "Mail Accounts" > "Mail...

Enabling Submission Port from Plesk control panel

If SMPT port 25 is not working from your end, kindly enable Submission Port from Plesk.It's very...

Creating FTP account

FTP account is created upon adding a domain in Plesk.If you have not yet added your domain in...

Creating an email account

To create an email account, login first to Plesk control panel.1. Click on Domains.2. Select your...