The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

mod_proxy in Apache

Discussion in 'EasyApache' started by sergiolobo, Jan 9, 2004.

  1. sergiolobo

    sergiolobo Registered

    Joined:
    Jan 9, 2004
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Does anyone know how to install mod_proxy in Apache without destroying any CPanel stuff? I talked to the EV1Servers.net support but they answered with something like "don't touch anything". :)
     
  2. trakwebster

    trakwebster Well-Known Member

    Joined:
    Jan 29, 2003
    Messages:
    145
    Likes Received:
    0
    Trophy Points:
    16
    I tried it and failed. I went to elance.com, and hired somebody (a russian whiz named Yuri Subach, from whirix company, email info@whirix.com), who did it for me.

    What he basically did was to create for me (in the root directory) a folder named MyApache and recompiled there, which involved first a 'configuration' step and then a recompile. I've not had to do a cpanel apache recompile yet, so I don't yet know for certain whether cpanel will break it. [Additional note 6/15/04 -- I recently did run /scripts/easyapache to do a necessary apache security upgrade, and it did NOT break the mod_proxy installation.]

    My reason for doing this apache work was to install the plone content management system, which I will say is *wonderful*. You can see my running site using plone at http://www.24metro.com. Plone in turn uses the Zope application server, which can apparently do other handy things as well. More info on plone at http://www.plone.org and zope at http://www.zope.org.

    For plone to run behind apache -- which is a wise and good thing -- apache needs to be able to proxy and re-write. I don't know if your situation is exactly similar, but for your info I will append here the notes I made about how this was all done. I'm not going to try to translate it all to be more generalized; I'd probably be as likely to mislead as to assist. If this appended info does not prove useful, the info does exist on the apache.org site, though I wasn't knowledgeable enough to follow it correctly. In these notes the domain used (fakebook.com) as just a test domain, and has been since disabled, but the 24metro.com domain is working, on plone, proxied behind apache, at http://www.24metro.com.

    If this should fail for you or be beyond your tech skills, you could go to elance or contact Yuri. He came in on time and on budget for me, and I'll hire him again when needed.

    ===== ATTACH APACHE PROXY NOTES HERE =====

    *** HOWTO install mod_proxy module into apache ***


    Overview:
    ========
    In order for apache to act as the front end for Zope and the Plone applications, the apache must have the mod_rewrite and the mod_proxy modules installed. Once installed, they are dynamically loaded using LoadModule and AddModule directives inside the httpd.conf file. The cpanel default includes the mod_rewrite, but the mod_proxy must be added.

    In the Zope directory, the presence (in zope root directory) of the VirtualWebMonster program (with no mappings set) works with the mod_proxy and rewrite rules so that three things happen:

    1. Apache receives an address like www.domain.com and translates it to a long string and sends it off to port 8080, where VirtualWebMonster makes the varioius Zope code work as if that address was actually www.domain.com.
    2. In the browser window, because apache is proxying, the visitor sees only www.domain.com
    3. Apache's version 1.3.xx mod_proxy module also caches the pages, so they're served up quickly. (One second compared to four or five seconds when created anew by Zope.)



    Installation instructions from whirix (Yuri Subach, hired on elance):
    =================================================

    0) The first step to modifying apache is to download apache in the same version as I am running --

    (a) So find out what version is running:
    Run: httpd -v
    This returns the apache version, so you know what apache to download.
    ACNOTE: You must run /usr/local/apache/httpd, because there's *another* so-called
    hpptd which is really a link to apachectl which has different flags and output.

    (b) To obtain the current tarball matching the running version:
    Goto: http://www.apache.org
    Follow by links to find:
    ''HTTP Server''->''from a mirror''
    It will take you to http://httpd.apache.org/download.cgi
    You can find needed version of apache here.
    Download the apache tarball to some handy directory, for example /root/MyApache/


    1) Extract apache source tarball to some directory, see /root/MyApache/

    2) configure apache
    bash-2.05a# ./configure --prefix=/usr/local/apache --enable-module=proxy --enable-shared=proxy

    3) build proxy module
    bash-2.05a# cd ./src/modules/proxy
    bash-2.05a# make

    4) install it
    bash-2.05a# /usr/local/apache/bin/apxs -i -a -n "proxy" libproxy.so

    5) restart apache
    bash-2.05a# /usr/local/apache/bin/apachectl stop
    /usr/local/apache/bin/apachectl stop: httpd stopped
    bash-2.05a# /usr/local/apache/bin/apachectl startssl
    [Thu Dec 11 09:13:21 2003] [warn] Loaded DSO libexec/libproxy.so uses plain Apache 1.3 API, this module might crash under EAPI! (please recompile it with -DEAPI)
    /usr/local/apache/bin/apachectl startssl: httpd started

    You should ignore issued warning, please see explanaition here:
    http://lists.over.net/pipermail/mod_gzip/2001-June/005213.html
    They talk about gzip, but proxy also doesn't need EAPI

    6) change thefakebook.com domain config
    #### START HERE ####
    <VirtualHost 64.191.95.140>
    ServerAlias www.thefakebook.com thefakebook.com
    ServerAdmin webmaster@thefakebook.com

    RewriteEngine on
    RewriteRule ^/(.*) http://localhost:8080/VirtualHostBa...oc re virtual host monster for correct syntax

    BytesLog domlogs/thefakebook.com-bytes_log
    ServerName www.thefakebook.com
    CustomLog domlogs/thefakebook.com combined
    </VirtualHost>
    #### END HERE ####

    7) restart apache



    SECURITY: Controlling access to your proxy:
    ==========================================
    You can control who can access your proxy via the <Proxy> control block as in the following example:

    <Proxy *>
    Order Deny,Allow
    Deny from all
    Allow from 192.168.0
    </Proxy>

    For more information on access control directives, see mod_access.

    Strictly limiting access is essential if you are using a forward proxy (using the ProxyRequests directive). Otherwise, your server can be used by any client to access arbitrary hosts while hiding his or her true identity. This is dangerous both for your network and for the Internet at large. When using a reverse proxy (using the ProxyPass directive with ProxyRequests Off), access control is less critical because clients can only contact the hosts that you have specifically configured.

    IS THIS NEEDFUL when using REWRITE RULES, or ONLY WHEN USING PROXY-PASS?

    ===== END APACHE PROXY NOTES HERE =====

    Hope you find this info useful!
     
    #2 trakwebster, Jan 9, 2004
    Last edited: Jul 2, 2004
  3. sergiolobo

    sergiolobo Registered

    Joined:
    Jan 9, 2004
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    First of all, thank you for your help!

    I managed (after many hours) to install mod_proxy the way I needed. I believe I took a simpler approach and I am sending it to you for you to compare. Just 4 steps:

    1- create libproxy.so (just execute the commands below)
    /home/cpapachebuild/buildapache/apache_1.3.29/config.status
    cd /home/cpapachebuild/buildapache/apache_1.3.29/src/modules/proxy
    make Makefile.tmpl libproxy.so

    2- copy the libproxy.so to /etc/httpd/libexec
    3- ajust httpd.conf
    LoadModule proxy_module libexec/libproxy.so
    AddModule mod_proxy.c
    <IfModule mod_proxy.c>
    ProxyRequests On
    ...
    4- restart apache

    Thank you again,
    Sergio Lobo
     
  4. peruda.com

    peruda.com Well-Known Member

    Joined:
    Aug 23, 2003
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    6
    I can't tell you how much I appreciate everyone's help here - I've been spending hours trying to figure mod_proxy out! I did run into a problem however -- After running this command (from /home/installd/buildapache/apache_1.3.29/src/modules/proxy):

    # make Makefile.tmpl libproxy.so

    I got the following errors:

    make: Nothing to be done for `Makefile.tmpl'.
    make: *** No rule to make target `libproxy.so'. Stop.


    Did anyone run into this problem? Any ideas?

    Thanks so much!
    -Hoover
     
  5. peruda.com

    peruda.com Well-Known Member

    Joined:
    Aug 23, 2003
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    6
    OK, I answered my own question. Apparently in the current CPanel build, even running the config.status script does not prepare the makefile for the proxy module. All I had to do was a simple hack to the config.status script -- I added the following lines after the "--enable-shared-rewrite" \ line.

    "--enable-module=proxy" \
    "--enable-shared=proxy" \


    After this, I was able to successfully complete Sergio's instructions.

    Hope that helps someone who needs to get mod_proxy going! Thanks again to everyone for their help.
    -Hoover
     
  6. deddy

    deddy Well-Known Member

    Joined:
    Oct 13, 2003
    Messages:
    131
    Likes Received:
    0
    Trophy Points:
    16
    Here the way for newbees :

    cd /home/cpapachebuild/buildapache/apache_1.3.31/src/modules/proxy/

    run command:

    /usr/local/apache/bin/apxs -i -c *.c

    mod_proxy has been created and placed straight
    into the libexec directory.

    add the following module directives to the httpd.conf:

    LoadModule proxy_module libexec/mod_proxy.so
    AddModule mod_proxy.c

    run command:
    /sbin/service httpd restart

    DONE ! :p
     
  7. albatroz

    albatroz Well-Known Member

    Joined:
    Mar 6, 2003
    Messages:
    258
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Virtual Orbis / Peru
    cPanel Access Level:
    Root Administrator
    Cool!
    Thanks Deddy...
     
  8. anup123

    anup123 Well-Known Member

    Joined:
    Mar 29, 2004
    Messages:
    897
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    This Planet
    I can't even find that apache_1.3.31 directory in my /home/cpapachebuild/buildapache directory

    I am running apache_1.3.31 for sure.
    So how to get that directory as it seems to be not there for me.

    TIA
    Anup
     
  9. deddy

    deddy Well-Known Member

    Joined:
    Oct 13, 2003
    Messages:
    131
    Likes Received:
    0
    Trophy Points:
    16
    You should update your apache using WHM
    or /scripts/easyapache
     
  10. anup123

    anup123 Well-Known Member

    Joined:
    Mar 29, 2004
    Messages:
    897
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    This Planet
    Thanks a lot.
    I am just posting the following info for users who are using mod_gzip and would want to use mod_proxy for a backend mod_perl httpd. mod_proxy would not work with mod_gzip at least that's what i finally managed to figure out . Reasons not known.

    I shifted all gzipping to backend httpd running mod_perl and removed mod_gzip from front end httpd. It worked.

    Thanks a lot once again.

    Anup
     
  11. anup123

    anup123 Well-Known Member

    Joined:
    Mar 29, 2004
    Messages:
    897
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    This Planet
    mod_gzip and mod_proxy won't work together

    If planning to use mod_proxy and mod_gzip, ensure that mod_gzip is used on proxied server and not proxying server.

    mod_gzip is broken because of which if used in conjunction with mod_proxy, errors of the following type are bound to occur if being proxied to a mod_perl server:

    File Not Found proxy:http://......../perl/someperlscript?somequerystring.

    Perhaps there could be a patch from the author of mod_gzip or cPanel

    Anup
     
  12. anup123

    anup123 Well-Known Member

    Joined:
    Mar 29, 2004
    Messages:
    897
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    This Planet
    In case mod_gzip and mod_proxy have to work together, then mod_gzip.c needs to be patched and compiled back in. I have finally managed to get the same working so mod_gzip + mod_proxy together is workable after patching mod_gzip.c

    If need a patch to mod_gzip.c PM me

    Thanks
    Anup
     
  13. computerworld

    computerworld Member

    Joined:
    Nov 25, 2004
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    I was browsing the Internet for a solution and got your thread and posted some problems that I have been facing. I guess you already solved this problem with a similar configuration. Thx...

    http://forums.cpanel.net/showthread.php?p=154578&posted=1#post154578
     
  14. bangsters

    bangsters Well-Known Member

    Joined:
    Jun 28, 2004
    Messages:
    77
    Likes Received:
    0
    Trophy Points:
    6
    Hi. Thanks for the posts regarding mod_proxy. I have set it up just as you guys mentioned here, and I believe it is running on my server. however, when I try to use this I get this error:

    Proxy Error
    The proxy server received an invalid response from an upstream server.
    The proxy server could not handle the request GET /voice1/.

    Reason: Could not connect to remote machine: Connection timed out

    Is there something wrong with my setup?

    Thanks
     
  15. teknoart

    teknoart Registered

    Joined:
    Nov 27, 2005
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Thanks!!

    Hi there!

    Just to thank you guys for this thread! After HOURS of trying to make it work (I needed mod_proxy for Plone as well), I finally managed to make it work!

    Thanks! :D
     
  16. wrapdida

    wrapdida Registered

    Joined:
    Aug 25, 2006
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    I can't find this folder and I tried updating Apache in WHM but I Dont see mod_proxy.
    Under environment:
    WHM 10.8.0 cPanel 10.8.2-R119
    CentOS 4.3 i686 - WHM X v3.1.0
     
Loading...

Share This Page