NGINX with Reverse Proxy
This document explains how to install NGINX with Reverse Proxy on a server that runs cPanel & WHM and EasyApache 4. This version of NGINX uses caching in order to serve content more quickly.
NGINX is an open source web server that also provides a reverse proxy, load balancing, and caching. cPanel & WHM’s NGINX with Reverse Proxy passes dynamic content through a proxy to Apache®.
When it comes to serving web pages, Apache and NGINX use different approaches. While Apache is deeply integrated into cPanel, NGINX currently serves a significant portion of websites worldwide. So, is it possible to use NGINX with cPanel?
The answer is yes, it is possible, but its integration is a bit complicated. While NGINX is faster than Apache at serving static content, it relies on external programs to handle processing and lacks the extensibility of Apache. Apache, on the other hand, is configurable and has superior customization and flexibility.
Despite the differences between the two, it is possible to take advantage of the strengths of both servers. One way is to use NGINX as a reverse proxy and cache. NGINX sits between the client and the server, serving static content quickly and passing dynamic content to Apache. It can also cache dynamic content for Apache, reducing server load and increasing performance.
Installing NGINX with Apache on a cPanel server is possible, but it is faster and easier to use a cPanel app called Engintron. It integrates NGINX with cPanel, configuring it as a reverse caching proxy for static files with a caching layer for dynamic content.
While NGINX support is still experimental, cPanel released an experimental version of EasyApache integrating NGINX, primarily focusing on WordPress support. Redirect and subdomain support were recently added to the experimental release. However, cPanel advises against using NGINX as an Apache replacement in production cPanel servers.
In conclusion, both Apache and NGINX excel in different situations, and the path forward for a standalone NGINX web server on cPanel servers is still a work in progress.
What Is NGINX, and How Does NGINX Work?
NGINX is a web server, load balancer, and reverse caching proxy. Like all web servers, it accepts HTTP requests and responds with HTML documents. NGINX was developed in response to perceived weaknesses in the way Apache handled network connections and requests.
Initially, Apache operated on a process-per-connection model, spawning a process for every web request. Each process was tied to a specific request and consumed a significant chunk of the host server’s resources, particularly memory. That model worked well on the early web, but modern web servers are expected to handle hundreds of concurrent connections, rapidly consuming the server’s resources.
NGINX, in contrast, has an asynchronous event-driven architecture. A master process controls worker processes, which respond to events, typically new connections, and each worker can handle multiple connections. Because workers are non-blocking, they respond to events as they occur, processing requests in turn rather than being dedicated to a single connection.