📦

Adding to cart!

BASIC Plan

Now let's choose your domain...

👤

Accessing your account!

My Webzi

Redirecting to client area...

Help Center

How to install and configure Nginx as a reverse proxy in cPanel/WHM 🚀

How to install and configure Nginx as a reverse proxy in cPanel/WHM 🚀

What is Nginx and why use it with cPanel?

Nginx is a high-performance web server that can function as a reverse proxy in front of Apache on cPanel servers. This configuration allows Nginx to handle static files (images, CSS, JavaScript) while Apache processes dynamic content (PHP), leveraging the strengths of both servers.

Prerequisites

  • Server with cPanel/WHM and root access
  • EasyApache 4 installed
  • At least 2GB of available RAM
  • 10GB of free space in /var for cache

Step-by-step installation

Step 1: Access EasyApache 4

  1. Log in to WHM as root
  2. Navigate to Software → EasyApache 4
  3. Click "Customize" on your current profile

Step 2: Install Nginx packages

In the "Additional Packages" tab, search for and install:

  1. ea-nginx - The base Nginx server
  2. ea-nginx-http2 - Support for HTTP/2 protocol
  3. ea-nginx-gzip - Gzip compression to reduce transfer size

Click "Next" then "Provision" to apply changes. The process will take 5-10 minutes.

EA-Nginx default configuration

Ports used

EA-Nginx automatically configures the following ports:

 
json
{
  "apache_port": "81",
  "apache_port_ip": "127.0.0.1",
  "apache_ssl_port": "444",
  "apache_ssl_port_ip": "127.0.0.1"
}
  • Nginx listens on ports 80 (HTTP) and 443 (HTTPS)
  • Apache moves to ports 81 and 444 internally

Default cache configuration

nginx
proxy_cache_valid 200 301 302 60m;  # Successful responses: 60 minutes
proxy_cache_valid 404 1m;           # 404 errors: 1 minute

Cache files are stored in /var/cache/ea-nginx/proxy/

Configuration file locations

  • Global configuration: /etc/nginx/nginx.conf
  • Per-user configuration: /etc/nginx/conf.d/users/[username].conf
  • Templates: /etc/nginx/ea-nginx/
  • Logs: /var/log/nginx/

Common issues and considerations

1. Dynamic content caching

Problem: The 60-minute cache can cause website changes to not appear immediately.

Symptoms:

  • Clients report their changes don't appear
  • Updated content doesn't reflect
  • Forms seem to not work correctly

Solution: Clear cache from WHM → Nginx Manager → Clear Cache

2. .htaccess compatibility

Problem: Nginx doesn't process .htaccess files. Rewrite rules, redirects, and security configurations in .htaccess won't work for static files.

Impact:

  • Custom redirects may fail
  • Directory protection may not apply
  • Custom cache rules ignored

3. Disk space usage

Cache can grow considerably:

  • 100 sites ≈ 5GB
  • 500 sites ≈ 25GB

This space is NOT counted in cPanel user quotas.

4. Duplicate logs

Logs are generated in both Nginx and Apache, duplicating space usage and complicating analysis.

How to uninstall Nginx

If you need to revert changes:

  1. In WHM → EasyApache 4 → Additional Packages
  2. Uncheck ea-nginx packages
  3. Provision to apply changes
  4. Clean residual cache:
    bash
    rm -rf /var/cache/ea-nginx/

Monitoring and maintenance

Verify HTTP/2 status

bash
curl -I --http2 -s https://your-domain.com | grep HTTP
# Should show: HTTP/2 200

Clear cache manually

bash
# For all sites
rm -rf /var/cache/ea-nginx/proxy/*

# Restart Nginx
systemctl restart nginx

When is implementing Nginx worth it?

Ideal scenarios:

  • Sites with lots of static content (images, videos)
  • Servers with high concurrency (>100 simultaneous visitors)
  • When server CPU constantly exceeds 70%
  • Well-optimized sites needing that extra speed boost

Scenarios where it's NOT recommended:

  • Sites requiring frequent changes and real-time updates
  • Applications heavily dependent on .htaccess configurations
  • When support team isn't familiar with Nginx
  • Sites with slow backends (the problem will persist)

Important considerations

Speed improvement with Nginx is most noticeable on already optimized sites. A site with slow database queries or poorly optimized code will remain slow, even with Nginx. Technology isn't a magic solution for programming issues.

The 60-minute cache can confuse users expecting immediate changes, leading to unnecessary support tickets or, worse, the perception that the hosting service has problems.


Need help with Nginx on your server?

At Webzi, we specialize in implementing and optimizing Nginx on cPanel servers. We understand both the benefits and complexities of this configuration.

If you need:

  • Evaluate if Nginx is right for your project
  • Custom implementation on your VPS or dedicated server
  • Configuration optimization for specific cases
  • Troubleshooting cache or compatibility issues

Contact us and our engineering team will evaluate your particular case. We can offer custom solutions, from special configurations to migration to servers specifically optimized for your type of application.

Remember: each project is unique and what works for one may not be ideal for another. At Webzi, we prefer to analyze each case individually to recommend the best technical solution, whether it's Nginx, LiteSpeed, or traditional Apache configuration.

Let's get started!

Start TODAY for just $3.45/mo

Includes website builder, 30GB cloud storage, 200+ apps and professional email.

Intuitive panel
24/7 Support
Website builder
Get Started

30-day money-back guarantee