I have server1 and server2. Server1 is conneted to internet with dns server and apache, serving 3 domains, abc.com, def.com and ghi.com. Ip address of server1 is 192.168.0.100. server2 is an internal server running apache with 3 domains, xyz.com, tuv.com and qrs.com. Ip address of server2 is 192.168.0.101. I want to have access of xyz.com from internet, so have to configure the dns of xyz.com on server1 and make apache redirect it to server2. The apache configuration for xyz.com on server1 is: <VirtuaHost 192.168.0.100> ServerName www.xyz.com ProxyRequests off Proxyass / http://192.168.0.101 proxyPassReverse / http://192.168.0.101 </VirtualHost> When I access www.xyz.com, server1 ir redirecting the ip address to server2, not the name server, so it gets the first domain in 192.168.0.101. A solution for that is to give a second ip address for the nic on server2, and configure xyz.com on that ip address, for example, 192.168.0.102 and on server1 <VirtuaHost 192.168.0.102> ServerName www.xyz.com ProxyRequests off Proxyass / http://192.168.0.102 proxyPassReverse / http://192.168.0.102 </VirtualHost> This way it works. is there another way to configure it? Thanks.
I think you are mixing name based virtual hosting with ip based virtual hosting. Try the below steps (1) Put DNS entry so xyz.com -> 192.168.0.100 (2) So abc.com, def.com, ghi.com and xyz.com now point to .100 (server1) and the rest tuv.com & qrs.com point to .101 (server2). (3) Create a new DNS entry ex: 123.com point to .101 (server2). This will be substitute for xyz.com (4) Create virtual hosts abc.com, def.com ,ghi.com and xyz.com on server1 as below Put below two lines somewhere under server1's apache main httpd.conf file and create a directory /etc/httpd/conf.d/virtual-hosts/ to hold virtual host config files. NameVirtualHost *:80 Include /etc/httpd/conf.d/virtual-hosts/*.conf (5) For each domain on server1, create virtual host config file under /etc/httpd/conf.d/virtual-hosts/abc.conf <VirtualHost *:80> ServerName www.abc.com ServerAdmin [email protected] DocumentRoot /<document root for abc> <other required options goes here> Create /etc/httpd/conf.d/virtual-hosts/def.conf,ghi.conf and xyz.conf as above. However for xyz.conf add below lines to facilitate proxy ProxyPass / http://www.123.com ProxyPassReverse / http://www.123.com (6) Create appropriate virtual hosts (tuv.com, qrs.com & 123.com) as above points (4) & (5) on server2. PS: I am assuming you don't want https as apache only supports 1 virtual host with named based virtual hosting. Hope this helps.
Thanks for your replay. Don't forget, in server1 I have all the domains on the Internet, so the DNS entries for these domains all points to 88.73.84.201 (a public address example). So, abc.com, def.com, ghi.com and xyz.com on server1 points to the public address, how can i configure another entry on the DNS of server1 telling DNS to points zyz.com to server2 (192.168.0.101)? Can I have 2 DNS entries on server1 saying for xyz.com to pints to 88.73.84.201 and another one pointing to 192.168.0.101?
You do you want XYZ point to server2 too? Do you also want XYZ to be accessed (may be internally) directly from Server2 whereas access via Server1 is only for External Internet connections? You could (1) Have your internal DNS only pointing to server2 for xyz.com whereas external dns points to server1 for xyz.com, or (2) Just access xyz.com as 123.com internally.