{"id":71,"date":"2010-10-09T13:14:42","date_gmt":"2010-10-09T13:14:42","guid":{"rendered":"http:\/\/sherinsunny.wordpress.com\/?p=71"},"modified":"2010-10-09T13:14:42","modified_gmt":"2010-10-09T13:14:42","slug":"nginx-as-reverse-proxy-for-apache-in-cpanel-server","status":"publish","type":"post","link":"https:\/\/linuxmaster.in\/?p=71","title":{"rendered":"Nginx as Reverse proxy for Apache in Cpanel Server"},"content":{"rendered":"<p>The steps are given below:<\/p>\n<p>    cd \/usr\/src<br \/>\n    wget http:\/\/sysoev.ru\/nginx\/nginx-0.7.63.tar.gz<br \/>\n    wget http:\/\/stderr.net\/apache\/rpaf\/download\/mod_rpaf-0.6.tar.gz<br \/>\n    wget ftp:\/\/ftp.csx.cam.ac.uk\/pub\/software\/programming\/pcre\/pcre-7.9.tar.gz<br \/>\n    tar xvzf mod_rpaf-0.6.tar.gz<br \/>\n    cd mod_rpaf-0.6<br \/>\n    \/usr\/local\/apache\/bin\/apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c<br \/>\n    cd \/usr\/src<br \/>\n    tar xvzf pcre-7.9.tar.gz<br \/>\n    cd pcre-7.9<br \/>\n    .\/configure<br \/>\n    make<br \/>\n    make install<br \/>\n    cd \/usr\/src<br \/>\n    tar xvzf nginx-0.7.63.tar.gz<br \/>\n    cd nginx-0.7.63<br \/>\n    .\/configure &#8211;with-http_ssl_module &#8211;with-http_realip_module &#8211;with-http_dav_module &#8211;with-http_flv_module &#8211;with-http_gzip_static_module<br \/>\n    make<br \/>\n    make install<\/p>\n<p>-Login to WHM and look for the following route:<br \/>\nMain &gt;&gt; Service Configuration &gt;&gt; Apache Setup &gt; Include Editor &gt; Pre Main Include<\/p>\n<p>&#8211; Add the following configuration and save, LIST_OF_YOUR_IPS changing the IP you occupy in your site:<\/p>\n<p>    LoadModule rpaf_module modules\/mod_rpaf-2.0.so<br \/>\n    RPAFenable On<br \/>\n    # Enable reverse proxy add forward<br \/>\n    RPAFproxy_ips 127.0.0.1 LIST_OF_YOUR_IPS<br \/>\n    # which ips are forwarding requests to us<br \/>\n    RPAFsethostname On<br \/>\n    # let rpaf update vhost settings<br \/>\n    # allows to have the same hostnames as in the &#8220;real&#8221;<br \/>\n    # configuration for the forwarding Apache<br \/>\n    RPAFheader X-Real-IP<br \/>\n    # Allows you to change which header mod_rpaf looks<br \/>\n    # for when trying to find the ip the that is forwarding<br \/>\n    # our requests<\/p>\n<p>Change the apache port to 81 (tweak settings)<br \/>\nOpen whm \u2013 tweak settings and find 0.0.0.0:80 and change it to 0.0.0.0.:81<\/p>\n<p>&#8211; Run SSH console<\/p>\n<p>    \/usr\/local\/cpanel\/whostmgr\/bin\/whostmgr2 &#8211;updatetweaksettings<br \/>\n    \/scripts\/rebuildhttpdconf<br \/>\n    httpd restart<\/p>\n<p>wget the automated nginx virtual host creator and run it<\/p>\n<p>http:\/\/prajizworld.com\/nginx.sh<\/p>\n<p>    \ufeffchmod 755 nginx.sh<\/p>\n<p>    .\/nginx.sh<\/p>\n<p>Remove the 3 # signs of the following lines from<\/p>\n<p> \/usr\/local\/nginx\/conf\/vhost.conf<\/p>\n<p>    \ufeff#location ~* \\.(gif|jpg|jpeg|png|wmv|avi|mpg|mpeg|mp4|js|css)$ {<\/p>\n<p>    # root   \/home\/myweb\/public_html;<\/p>\n<p>    #}<\/p>\n<p>Check nginx configuration  using<\/p>\n<p>    \/usr\/local\/nginx\/sbin\/nginx -t<\/p>\n<p> If everything is fine, its time to  start nginx.<\/p>\n<p>    \/usr\/local\/nginx\/sbin\/nginx<\/p>\n<p>Configure nginx startup script<\/p>\n<p>    http:\/\/prajizworld.com\/nginx.txt<\/p>\n<p>    mv nginx.txt \/etc\/init.d\/nginx<\/p>\n<p>    chmod +x nginx<\/p>\n<p>    \ufeffchkconfig &#8211;add &#8211;level 3  nginx<\/p>\n<p>After doing all these, the server load was very low and pages were processing at lightning fast,<\/p>\n<p>but still we experienced a slowness.<\/p>\n<p> When I analyzed the traffic, I understood now network is bottleneck.<\/p>\n<p>I could see many concurrent connections from same session downloading huge files.<\/p>\n<p> So I thought of adding the below lines to limit traffic from same session<\/p>\n<p>    ### Directive describes the zone, in which the session states are stored i.e. store in slimits. ###<br \/>\n    ### 1m can handle 32000 sessions with 32 bytes\/session, set to 5m x 32000 session ###<br \/>\n           limit_zone slimits $binary_remote_addr 5m;<\/p>\n<p>    ### Control maximum number of simultaneous connections for one session i.e. ###<br \/>\n    ### restricts the amount of connections from a single ip address ###<br \/>\n            limit_conn slimits 2;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The steps are given below: cd \/usr\/src wget http:\/\/sysoev.ru\/nginx\/nginx-0.7.63.tar.gz wget http:\/\/stderr.net\/apache\/rpaf\/download\/mod_rpaf-0.6.tar.gz wget ftp:\/\/ftp.csx.cam.ac.uk\/pub\/software\/programming\/pcre\/pcre-7.9.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 cd \/usr\/src tar xvzf pcre-7.9.tar.gz cd pcre-7.9 .\/configure make make install cd \/usr\/src tar xvzf nginx-0.7.63.tar.gz cd nginx-0.7.63 .\/configure &#8211;with-http_ssl_module &#8211;with-http_realip_module &#8211;with-http_dav_module &#8211;with-http_flv_module &#8211;with-http_gzip_static_module make make install -Login to WHM and &hellip; <a href=\"https:\/\/linuxmaster.in\/?p=71\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Nginx as Reverse proxy for Apache in Cpanel Server&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-71","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/linuxmaster.in\/index.php?rest_route=\/wp\/v2\/posts\/71","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxmaster.in\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxmaster.in\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxmaster.in\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxmaster.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=71"}],"version-history":[{"count":0,"href":"https:\/\/linuxmaster.in\/index.php?rest_route=\/wp\/v2\/posts\/71\/revisions"}],"wp:attachment":[{"href":"https:\/\/linuxmaster.in\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=71"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxmaster.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=71"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxmaster.in\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=71"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}