7

I have two Apache Servers with mod_proxy enabled. I want to know how to "pass the request" from "Apache Server A" to "Apache Server B" using the same port (80).

In "server A" with internal ip: 192.168.0.5 I have configured DNS and I am also using it as my mail server.

In "server B" with internal ip: 192.168.0.10 I have my own cloud server.

Today when I access wwww.mydomain.com or www.mydomain.com/webmail everything works because the content is all in "server A", what I need is when somebody tries to access owncloud.mydomain.com they can access my server B without redirecting them to another port like owncloud.mydomain.com:81, I just want to use port 80.

Actually I get a redirect loop because when I try to redirect I guess "SERVER A" is getting the same request by himself. I have set my virtualhost working in the same "SERVER A" what I want is to "redirect" to another server using the same port and URL (owncloud.mydomain.com).

I don't want to redirect using another port.

1
14

You're going to want to do something like this on Server A:

NameVirtualHost *
<VirtualHost *>
    ServerName owncloud.mydomain.com

    ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyPass / http://192.168.0.10:80/
    ProxyPassReverse / http://192.168.0.10:80/
    <Location />
        Order allow,deny
        Allow from all
    </Location>
</VirtualHost>

Depending on your application you may need to make use of one or all of the following:

  • X-Forwarded-For - The IP address of the client.
  • X-Forwarded-Host - The original host requested by the client in the Host HTTP request header.
  • X-Forwarded-Server - The hostname of the proxy server.

Take a look at the mod_proxy documentation for more tips and tricks.

References

3
  • It works. But i have another trouble, the owncloud server is in owncloud.mydomain.com/owncloud, how can i "redirect" to that path /owncloud. Now i have this in my server A: RewriteCond %{HTTP_HOST} ^owncloud\.mydomain\.com$ [NC] RewriteRule ^/(.*)$ owncloud.mydomain.com/$1 [P] How can i redirect to /owncloud THanks
    – maxtorzito
    May 27 '13 at 15:47
  • I'd ask it as another question.
    – slm
    May 27 '13 at 15:50
  • Here you have the question: serverfault.com/questions/511191/…
    – maxtorzito
    May 27 '13 at 16:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.