Customizing NGINX with Reverse Proxy in cPanel & WHM

This article explains how to customize NGINX with reverse proxy on cPanel & WHM servers. It covers global configuration settings, custom .conf files, server block customization, user-level configuration, Cloudflare management, file access restrictions, increasing worker processes, and enabling the X‑Cache‑Status header.ز

NGINX customizationreverse proxy configurationcPanel NGINX settings

~3 min read • Updated Feb 22, 2026

1. Overview


You can customize NGINX® with reverse proxy in several ways on a cPanel & WHM server. These customizations include global configuration settings, server block adjustments, user-level configurations, Cloudflare integration, file access restrictions, and performance tuning.




2. Global Configuration Settings


You can configure certain NGINX directives through WHM’s Global Configuration interface:

WHM » Home » Service Configuration » Apache Configuration » Global Configuration


The following settings correspond to NGINX directives:

  • Keep-Alivekeepalive When set to On, NGINX uses a value of 32. To use a custom value, edit /etc/nginx/ea-nginx/settings.json.
  • Keep-Alive Timeoutkeepalive_timeout NGINX uses only the value set in WHM.
  • Max Keep-Alive Requestskeepalive_requests If set to Unlimited, NGINX uses 1000.



3. Global Configuration Files


Place any global .conf files in:

/etc/nginx/conf.d/

To modify all server blocks, place your file in:

/etc/nginx/conf.d/server-includes/

Note: You must reference your file using an include directive.




4. Server Blocks


To customize NGINX server blocks (equivalent to Apache virtual hosts), create a .conf include file in the appropriate directory.


Each server block automatically includes files from:

/etc/nginx/conf.d/server-includes/

Warning: Do not use the prefix cpanel- for custom files.




5. User Configuration


Use the following paths to customize user-specific server blocks:

All server blocks for a user:

/etc/nginx/conf.d/users/username/

Specific domain:

/etc/nginx/conf.d/users/username/domainname/

Addon domains:

/etc/nginx/conf.d/users/username/addondomain.domainname/*.conf



6. Custom Server Configurations


Warning: Do not edit NGINX-owned files. Doing so may cause unexpected behavior.


To customize NGINX before installation, create:

/var/nginx/ea-nginx/settings.json
/var/nginx/ea-nginx/cache.json

During installation or rebuild, these files are copied to:

/etc/nginx/ea-nginx/settings.json
/etc/nginx/ea-nginx/cache.json

Supported directives in settings.json:

  • keepalive_time
  • worker_shutdown_timeout
  • worker_processes

Important: Files must contain valid JSON.




7. Manage Cloudflare Configuration


By default, NGINX configures Cloudflare proxies in:

/etc/nginx/conf.d/users/example.conf

To disable Cloudflare integration:

  • Add include_cloudflare: false to /etc/nginx/ea-nginx/settings.json.
  • Rebuild or restart NGINX.



8. Restrict File Access


To block access to sensitive directories (e.g., .git), create a .conf file and add:

location ~ /\.git {
    deny all;
    log_not_found off;
    access_log off;
    return 404;
}



9. Increase NGINX Worker Processes


To increase worker_processes:

  1. Edit /etc/nginx/ea-nginx/settings.json.
  2. Increase the worker_processes value (doubling is recommended).
  3. Test configuration:
nginx -t

If successful, restart NGINX.




10. Add the X-Cache-Status Header


To track cache behavior:

  1. Edit /etc/nginx/ea-nginx/cache.json.
  2. Change:
"x_cache_header": false,

to:

"x_cache_header": true,

Important: Do not remove the comma.


Rebuild NGINX to apply changes.




Conclusion


With these customization options, you can fine‑tune NGINX behavior on your cPanel & WHM server. From global settings to user‑level configurations, Cloudflare management, file access restrictions, and performance tuning, NGINX provides a flexible and powerful reverse proxy environment.


Written & researched by Dr. Shahin Siami