need to proxy from one VirtualHost to another

Discussion in 'Apache' started by jeanluca, Nov 6, 2008.

  1. #1
    Hi All

    I have two virtual host, which work both perfect. However, now I would like to proxy from one to the other if the URL is, lets say: example.com/other

    So what I added to this VirtualHost was:

    #ProxyPass /other http://other.local
    ProxyPassReverse /other http://other.local

    I've commented the first line, because I think I only need the second one.
    However this doesn't do anything. I've used things like this to proxy to an other server (which did work), but to an other VirtualHost doesn't seem to work

    Any suggestions
    Thnx
    LuCa

    ps other.local is defined in my /etc/hosts file
     
    jeanluca, Nov 6, 2008 IP
  2. jeanluca

    jeanluca Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I did some tests and noticed that I need ProxyPass (I get the impression that ProxyPassReverse only adjust the URL). So if I do:
    
       ProxyPassReverse /other http://www.google.com
       ProxyPass /other http://www.google.com
    Code (markup):
    it works. So what I think that happens when I try to proxy to the other virtualHost, the request comes back in the current virtualHost (because I get the wrong site)

    So I think it might help to give more configuration info:

    NameVirtualHost *:80
    <VirtualHost *:80>
        ServerAdmin root@localhost
        DocumentRoot /srv/www/
        ServerName www.example.com
        ErrorLog logs/localhost-error_log
        CustomLog logs/localhost-access_log common
        ProxyPreserveHost On
    
       ProxyRequests Off
    
      <Proxy *>
        Order deny,allow
        Allow from all
      </Proxy>
    
    
        ProxyPassReverse /other http://other.local
        ProxyPass /other http://other.local
       ....
    </VirtualHost>
    
    
    <VirtualHost *:80>
       ServerName other.local
       DocumentRoot /srv/backend/public
       ErrorLog logs/backend.local-error_log
       CustomLog logs/backend.local-access_log common
       #RailsEnv production
       RailsEnv development
       RailsAllowModRewrite off
       <directory "/srv/backend/public">
         Order allow,deny
         Allow from all
       </directory>
    </VirtualHost>
    Code (markup):
    Hope this helps, because I ran out of options :)

    thnx a lot
    LuCa
     
    jeanluca, Nov 7, 2008 IP
  3. jeanluca

    jeanluca Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I found a solution which is not the best, but good enough. Just give the second host a different port number, not a different host name.

    BTW, if someone can knows how to fix this problem as I described before, I'm still very interested!

    cheers
    LuCa
     
    jeanluca, Nov 7, 2008 IP