Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

So Confused myself, so I need an expert reverse proxy help here please.

Server 1 on Public IP - 173.xxx.xxx.xxx port 80 (LAN IP is 10.1.10.2).

Server 1 also has a local DNS enabler so that local users are able to browse all of our 4 registered domains within our local LAN.

Server 2 is on local LAN with local IP 10.1.10.2

First question is:

Where will my proxyPass statement below should go if I want my Server 2 to be accessible from the internet? Will go to Server 1 or Server 2. Or do I need to have the same statement for both Server 1 and Server 2? I tried putting this on either but I can not make it work. It sort of work once but users only see domain1.com all the time no matter which domain they use on their browser.

ProxyRequests Off
ProxyPreserveHost On
    <Proxy *>
     Order deny,allow
     Allow from all
    </Proxy>
    ProxyPass / http://WhichIPand:Port/
    ProxyPassReverse / http://WhichIPand:Port/

Question 2: httpd-vhosts.conf Can I continue using virtual hosts on both Server 1 and Server 2 ? I am currently using virtual host on Server 1 with 4 registered domains. I want to move 2 domains off of Server 1 to Server 2 so that,

Server 1 will have: domain1.com, domain2.com
Server 2 will have: domain3.com, domain4.com

Question 3: What would my host file look like for both Server 1 and Server 2 with each has 2 qualified domains. Will it be this way or put all local LAN IP on each Servers.

127.0.01 domain1.com
127.0.01 domain2.com
127.0.01 domain3.com
127.0.01 domain4.com

I know this may look too much, but this really will help a lot of people also other than me. But me, I am so lost right now and someone with a great mind and teaching skills should be able to help,

Thanks and merry christmas to all.


added this in response to Shane and Aaron:

This is what I got so far and its not getting me anywhere. maybe you can help and really thank you for your replies...

My Server 1 on public IP 173.1xx.1xx.xxx port 80 (LAN IP is 10.1.10.2) OSX Lion setup on virtual host: httpd-vhost.conf

With this setup, I am getting:

Service Temporarily Unavailable The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

NameVirtualHost *

<VirtualHost *:80>
ServerName domain1.com
ServerAlias www.domain1.com
ServerAdmin admin@domain1.com
DocumentRoot "/Library/WebServer/joomla"
ErrorLog /Library/WebServer/joomla/error_domain1.log
<Directory "/Library/WebServer/joomla">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All AuthConfig
    Order allow,deny
    Allow from all
</Directory>
ProxyRequests Off
ProxyPreserveHost On
    <Proxy *>
     Order deny,allow
     Allow from all
    </Proxy>
        ProxyPass / http://10.1.10.2:8080/
        ProxyPassReverse / http://10.1.10.2:8080/
</VirtualHost>


<VirtualHost *:80>
ServerName  domain2.com
ServerAlias www.domain2.com
ServerAdmin admin@domain2.com
DocumentRoot "/Library/WebServer/webb"
ErrorLog /Library/WebServer/webb/error_domain2.log
<Directory "/Library/WebServer/webb">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
ProxyRequests Off
ProxyPreserveHost On
    <Proxy *>
     Order deny,allow
     Allow from all
    </Proxy>
        ProxyPass / http://10.1.10.2:8080/
        ProxyPassReverse / http://10.1.10.2:8080/
</VirtualHost> 



My Server 2 on LAN IP: 10.1.10.2, OSX Snow setup on virtual host: httpd-vhost.conf

<VirtualHost *:80>
ServerName  domain3.com
ServerAlias www.domain3.com
ServerAdmin admin@domain3.com
DocumentRoot "/Library/WebServer/domain3"
ErrorLog /Library/WebServer/domain3/error_cj.log
<Directory "/Library/WebServer/domain3">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All AuthConfig
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>  


<VirtualHost *:80>
ServerName domain4.org
ServerAlias www.domain4.org
ServerAdmin admin@domain4.org
DocumentRoot "/Library/WebServer/domain4"
ErrorLog /Library/WebServer/domain4/error_fn.log
<Directory "/Library/WebServer/domain4">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All AuthConfig
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>  
share|improve this question
    
Where are your ProxyPass statements located on server 1, and does it have vhosts for other sites? Does server 2 have vhosts for the sites that it's supposed to serve? –  Shane Madden Dec 21 '11 at 19:49
    
Hi - I edited above and added what I got, its not getting me anywhere. –  maximo Dec 21 '11 at 21:01
    
Ok, back up a bit - are you intending to send domain1 and domain2 requests to server 2, or domain3 and domain4? And is there any particular reason that your ProxyPass statements are pointing to port 8080 when both of your Apache listeners look to be on port 80? –  Shane Madden Dec 21 '11 at 21:36

2 Answers 2

  1. ProxyPass configuration would be part of Server 1's configuration. This is the host acting as the proxy for Server 2. You don't need to make any change to Server 2.

  2. You should be able to continue using vhosts. I got frustrated though and just setup my proxy with <location> statements. It works well for what I needed.

  3. I think you're just complicating things with local hosts files. Proxy Server 2 by IP instead? A local hosts file is not DNS so it won't change how other hosts access these systems. But, if you proxy Server 2 by FQDN, Server 1 will not be able to find it on localhost. It will need to be the internal LAN IP.

share|improve this answer
    
Thanks for your reply. Here is what I got so far and not good. –  maximo Dec 21 '11 at 20:55
    
Just Edited my original post to include all the my vhosts and proxy statements. NOt getting me anywhere. Thank you again. –  maximo Dec 21 '11 at 21:02

What it sounds like you're looking to do is this:

  • Server 1 is the publicly accessible server, and contains 4 sites:
    1. domain1.com, for which it serves the content
    2. domain2.com, for which is serves the content
    3. domain3.com, which it proxies to Server 2
    4. domain4.com, which it proxies to Server 2
  • Server 2 does not have a public address, and contains 2 sites:
    1. domain3.com, for which it serves the content
    2. domain4.com, for which it serves the content

If that's the case, then your Server 2 config looks good, and Server 1 should look something like this:

ProxyRequests Off
ProxyPreserveHost On
NameVirtualHost *

<VirtualHost *:80>
    ServerName domain1.com
    ServerAlias www.domain1.com
    ServerAdmin admin@domain1.com
    DocumentRoot "/Library/WebServer/joomla"
    ErrorLog /Library/WebServer/joomla/error_domain1.log
    <Directory "/Library/WebServer/joomla">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All AuthConfig
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName  domain2.com
    ServerAlias www.domain2.com
    ServerAdmin admin@domain2.com
    DocumentRoot "/Library/WebServer/webb"
    ErrorLog /Library/WebServer/webb/error_domain2.log
    <Directory "/Library/WebServer/webb">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName domain3.com
    ServerAlias www.domain3.com
    ServerAdmin admin@domain3.com
    ProxyPass / http://10.1.10.2:80/
    ProxyPassReverse / http://10.1.10.2:80/
</VirtualHost>

<VirtualHost *:80>
    ServerName domain4.com
    ServerAlias www.domain4.com
    ServerAdmin admin@domain4.com
    ProxyPass / http://10.1.10.2:80/
    ProxyPassReverse / http://10.1.10.2:80/
</VirtualHost>

And yeah, as Aaron suggested, clear out the hosts files - they're just confusing matters.

share|improve this answer
    
My god, it works and really work. I just have to test it from outside the LAN later. Do I need to add this <Proxy *> Order deny,allow Allow from all </Proxy> –  maximo Dec 21 '11 at 22:40
    
@user104482 Nope, it's unnecessary; it's implied in a reverse proxy deployment like this. –  Shane Madden Dec 21 '11 at 22:43
    
This is the first thread that the question about reverse is really clear. I hope other folks will also see this. I checked everywhere and no post was presented their story this way. Perfect and concise. You guys have a great christmas. –  maximo Dec 21 '11 at 22:45
    
One more question folks - My Server 1 as you know is listening on port 80 since its where my router is NATed to. My Server 2 on the other hand, which is in the LAN 10.1.10.2 and has the domain3.com and domain4.com. Its listening on port 80 also? my virtual hosts statement says <VirtualHost *:80>. This server was originally NATed to port 80 then I left it how it was, but it works. I guess it does not matter if its 80 or 9595, ha? –  maximo Dec 22 '11 at 0:04
    
@user104482 You'll have a Listen directive somewhere in your config that determines what port they're listening on - but yes, your current config has both systems listening on port 80, which should work just fine for your needs. –  Shane Madden Dec 22 '11 at 0:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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