Snappy

Helpdesk Support

Official Supportmonk Company Blog!

NginxCP: Cpanel reverse proxy

May 9, 2013 , 10:49 pm


nginx_logoNginx is one of the high performance web server. It can be configured as reverse proxy in cpanel server to improve the site performance. In this article, I would like to discuss about configuring nginx as reverse proxy in cpanel server.

nginxCP is a cpanel plugin that is used to manage nginx service in cpanel server. As we know that nginx can handle static contents better than apache, we will configure nginx to run on port 80 and will forward dynamic requests to apache on port 8081. To configure nginx as revcrse proxy, we need to install an apache module mod_rpaf.

Mod_rpaf installation:

Login as root:
# cd /usr/local/src
# wget https://nginxda.googlecode.com/files/mod_rpaf-0.6.tar.gz
# tar xvzf mod_rpaf-0.6.tar.gz
# cd mod_rpaf-0.6
# /usr/local/apache/bin/apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c

For Apache 2.4 : You need to apply a patch for mod rpaf

==================
git clone git://gist.github.com/2716030.git
patch mod_rpaf-0.6/mod_rpaf-2.0.c 2716030/mod_rpaf-2.0.c.patch
==================

 

You can change apache port to 8081 from your whm tweak settings.

WHM > Server Configuration > Tweak Settings > Apache non-SSL IP/port

 

Now you need to install nginxCP plugin. You can check the steps given below.

=====================
# cd /usr/local/src
# wget http://nginxcp.com/latest/nginxadmin.tar
# tar xf nginxadmin.tar
# cd publicnginx
# ./nginxinstaller install
====================

To server static files using nginx, you have to  convert apache virtualhost to nignx virtualhost. You can download the script at http://blog.supportmonk.com/nginx.txt ,  rename it as nginx.sh , provide 755 permission and execute it. You have to create an empty file /usr/local/nginx/conf/vhost.conf

====================
# touch /usr/local/nginx/conf/vhost.conf
# wget  http://blog.supportmonk.com/nginx.txt
#  cp nginx.txt nginx.sh
# chmod 755 nginx.sh
# ./nginx.sh
===================

Configuration is complete. You can test nginx configuration and can start it.

=========================
# root@server [~]# /usr/local/sbin/nginx -t
# nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
# nginx: configuration file /etc/nginx/nginx.conf test is successful

# /etc/init.d/nginx start
=========================

 

Envelope Icon

Get Updates Your Email!

Subscribe to Supportmonk and receive blog posts to your email!

Subscribe Via Email

SupportMonk on Facebook


Outsourced Customer Support