User Tools

Site Tools


The plugin described here has known compatibility issues with CentOS 7, and is unlikely to work with that version of CentOS. With older versions of CentOS, there may also be bugs and/or inconsistent behavior. Since the plugin is 3rd-Party, it is only supported on a Best Effort basis. Problems with the plugin itself should be directed to its developer.

How can I install nginx as a reverse proxy on cPanel?

By default cPanel uses Apache as the web server. However custom cPanel plugins have been created to take advantage of nginx's speed and utilize it as a reverse proxy.

Numerous articles can be found about the comparisons and differences between Apache and nginx, however this quote from WikiVS summarizes it nicely.

nginx is faster at serving static files and consumes much less memory for concurrent requests because Nginx is event-based it doesn't need to spawn new processes or threads for each request, so its memory usage is very low has found nginx to be the only load balancer able to handle 8000 live traffic requests per second.

How can I install nginx as a reverse proxy on cPanel?

For an automated installation script by KnownHost's Technical Staff, please scroll to the bottom of the page for further instructions.

By default, KnownHost's VPS's have the plugin directory created, however on plain vanilla installs of cPanel, you'll need to either create the apps directory (step 6). For KnownHost server's you can skip step #6.

Installing nginx as a reverse proxy on cPanel will require knowledge and use of SSH/Terminal commands. Also, please note this plugin is developed and supported by NginxCP and KnownHost can not be held responsible for any issues related to this plugin.

  1. Login to your server via SSH (as root).
    • ssh root@<ip address> -p 2200
  2. Once logged in successfully, you'll need to change into the /usr/local/src directory.
    • cd /usr/local/src
  3. Now, simply download the plugin using wget.
  4. Now that it's been downloaded, you need to extract the compresssed plugin.
    • tar xf nginxadmin.tar
  5. Change into the publicnginx directory.
    • cd publicnginx
  6. Following documentation from cPanel's Create WHM Plugins, we'll need to create the apps directory. ( KnownHost Servers won't need this step! )
    • mkdir /var/cpanel/apps && chmod 755 /var/cpanel/apps
  7. Run the included executable installer program with the 'install' flag.
    • ./nginxinstaller install
    • If you've never setup a Remote Access Key, you'll see the following error: access key doesn't exist To fix this, you'll need to login to WHM, visit the "Clusters" section, select " Remote Access Key" then select "Generate New Key". It should look like this:
    • If all goes smoothly, the end result should print something similar to the following:
      •  ****************************************************
         *               Installation Complete              *
         *run /etc/init.d/httpd restart to start Nginx Admin*
  8. Restart the webserver daemon.
    • /etc/init.d/httpd restart
      • Which should result with output similar to this:
      • Restarting nginx daemon: nginxRemaining processes: 10207
  9. Now that it's installed and running properly, you'll need to register the app/plugin via cPanel's register_appconfig:
    • /usr/local/cpanel/bin/register_appconfig /var/cpanel/apps/nginxcp.conf

* Which should result with output similar to this:

  • nginxcp registered

NginxCP (nginx as a reverse proxy) is now installed and can be viewed/accessed/configured via WHM. To access the Control Panel for nginx, visit your WHM Panel » Plugins » nginx Admin.

Creating automated temp files cleanup

While using nginx as a reverse proxy has it's many benefits, not creating an automated temp cleanup can result in adverse performance.

  1. Running crontab -e (for edit) opens /var/spool/cron/root as a temporary file for editing purposes. Perform the following:
    • crontab -e
  2. Add the following to the end of the list, ensuring not to edit existing rules:
    • 0 */1 * * * /usr/sbin/tmpwatch -am 1 /tmp/nginx_client
    • Press [CTRL] + X to save the changes. You'll be prompted, "Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES) ?" Press Y and then [Enter].
    • You'll again be prompted, something similar to, "File Name to Write: /tmp/crontab.XXXXXX" , simple press [Enter] at this time.
    • /usr/bin/crontab: installing new crontab
    • This output confirms the new cron job was successfully installed.

KnownHost's completely automated installation script

This script is meant for KnownHost's server only and should be used *at your own risk*.

  1. As the root user in your VPS, copy and paste the following line into the SSH/Shell Terminal:

Check out the GitHub Repository for this script: kh_nginxcp

Use of nginx with cPanel and WHM is not officially supported by cPanel.

control-panels/cpanel-whm/how-can-i-install-nginx-as-a-reverse-proxy-on-cpanel.txt · Last modified: 2017/09/08 10:08 by Daniel P.