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

---
  • 0 Benutzer fanden dies hilfreich
  • War diese Antwort hilfreich?

    Verwandte Artikel

    How To: Back Up MySQL Databases From The Command Line

    While automated backups are important, sometimes you just want to take a quick and dirty snapshot...

    How To Install MariaDB on CentOS 6

    MariaDB is a drop-in replacement for MySQL. It is easy to install, offers many speed and...

    How to Display (List) All Jobs in Cron / Crontab

    View Root’s Cron Jobs crontab -l  View a User’s Cron Jobs crontab -u username -l Example with...

    How To: Automate Server Scripts With Cron

    Servers can automatically perform tasks that you would otherwise have to perform yourself, such...

    How to find sending spam emails and enable mail header in php.ini

    - In Linux servers if there are a lot of emails in the queue "over 100" emails. you can check if...