Skip to content Skip to footer

Install Nginx on cPanel To Improve Your Website’s Performance

One of the best options to improve performance and security for your websites is to use Nginx. Unfortunately, the default installation of cPanel does not ship with Nginx. In this guide, we’ll explain how to install Nginx on cPanel servers using an open source software called Engintron.

A reverse proxy provides a layer of hardware abstraction which makes it easier to ensure that users have constant access to the content they have requested. In cases where the reverse proxy server sits behind a firewall in a private server network, it is also extremely secure.

One of the best ways to improve the performance and security of a web server it to install a reverse proxy server. It acts as an intermediary server that forwards requests for content from multiple clients to other backend servers.

Why install nginx on cPanel?

There are a several reasons to run nginx as a reverse proxy on your servers:

Improved server performance

A reverse proxy can compress inbound/outbound data and cache the content that is frequently used by the server, which speeds up server requests. It can also perform tasks like SSL encryption and the serving of static content, which further reduces the load on your web server.

Improved Security

Reverse proxies are useful for hiding the topology and technical details of back-end servers, which reduces the risk of server intrusions by malicious third parties. Your back end servers won’t be accessible directly via the Internet, which provides an additional layer of protection.

Load Balancing

Having a reverse proxy makes it simple to distribute user requests across multiple backend servers. This increases server speed and stability by ensuring no single server is overloaded. If a server does experience a technical issue, traffic can automatically be directed to other backend servers. This great article goes into more detail on the benefits of using nginx..

Why Is Nginx A Great Reverse Proxy?

Nginx is a high-performance web server that is fast, lightweight, and simple to configure. The key difference between Nginx and Apache is that Nginx is event-based while Apache is process-based. Nginx will not spawn new processes for each request, which means it uses less memory for concurrent requests and serves static files faster than Apache.

In addition to being a world class web server, Nginx can operate as a reverse proxy, mail proxy, load balancer, and HTTP cache. Its versatility, excellent performance, and small footprint are the reason why it is considered a best-in-class option currently available.

How to Install Nginx on cPanel

cPanel is the world’s leading web server control panel. It provides users with dozens of powerful features and an easy-to-use interface which makes managing a server simple. However, it does not come with Nginx, so we need to install it. The easiest way to do so is by using a third party cPanel plugin, like Engintron.

To install Engintron, you will need root SSH access to your cPanel server. Once you have logged in, execute the following commands:

Step 1. Installation

cd /; rm -f engintron.sh; wget --no-check-certificate https://raw.githubusercontent.com/engintron/engintron/master/engintron.sh; bash engintron.sh install

It will take several minutes for the installation to complete.

Step 2. Configuration for Cloudflare (Optional)

If you are using CloudFlare for any of your websites, apply the following changes depending on your setup:

A. If you server has only one IP Address, edit the file /etc/nginx/custom_rules and append the following line at the bottom of the file:

set $PROXY_DOMAIN_OR_IP "XXX.XXX.XXX.XXX";

Add your servers main public IP Address between the double brackets “XXX”

B. If your server has more than 1 IP Address, edit /etc/nginx/custom_rules, in addition to “A” configuration above, append the following line for EACH of your domains having a dedicated IP:

if ($host ~ "example.com") {
     set $PROXY_DOMAIN_OR_IP "XXX.XXX";
     }

Once you finish the installation, head over to your WHM control panel and log in. You will now see Engintron in the plugins section.

Nginx and Engintron Documentation

Click on the Engintron link to view the options that are available. You also have complete control over Nginx’s configuration files. Engintron will automatically setup Nginx to speed up delivery of both static and dynamic content.

You can also find some useful utilities in the Engintron settings, including access/error logs and server monitoring. If you require more information, view Engintron documentation and Nginx documentation.

Furthermore, you may read our article for bad bot blocking for nginx in order to further secure your server. If you wish to install and configure nginx on your cPanel server, see our cpanel server management plans.

Thanks for reading our tutorial Install Nginx on cPanel. In the next article, I’ll share some essential information for using nginx rules to limit abusive behaviour towards websites.

Leave a comment