View Full Version : [ubuntu] Point Subdomain to second server?
jamieh
February 14th, 2009, 01:37 PM
I have two web servers on the same network, behind the same router (a Linksys BEFSX41), and I have several subomains for my domain set up with VirtualHost entries.
How would I go about pointing a subdomain to the OTHER server, while still using Port 80?
With my router, (AFAIK) you can only forward a port to one server...
mydomain.com > Server A
sub.mydomain.com > Server A
othersub.mydomain.com > Server B
Server A is 192.168.6.107
Server B is 192.168.6.108.
How would I go about doing this?
Thanks
HermanAB
February 14th, 2009, 03:02 PM
That should be done with DNS. BIND connects hostnames to IP addresses, TCP/IP does the rest.
Cheers,
Herman
hyper_ch
February 14th, 2009, 04:22 PM
his problem is that he's behind a router...
volkswagner
February 14th, 2009, 04:52 PM
Can't this be accomplished with ip directive in vhost file.
I was wondering this myself as I a trying to upgrade my server to new hardware. I have the email working on new server, but I need to transfer apache hosts. It would be nice if I could move one at a time and verify each was working with minimal downtime.
Can we use the following directive?
<VirtualHost ip.add.ress.otherserver>
Then the router won't need to forward to two servers on port 80 as this will be done inside LAN?
Obviously the second server would need a proper vhost running.
Or will this need to be done with a network share as the root directory?
volkswagner
February 14th, 2009, 05:25 PM
duh, I just realized that directive is for listening on multiple IP's. I can only think of a messy redirect.
JeppeM
February 15th, 2009, 07:53 AM
Hey,
What you're looking for is the an transparent apache proxy... You need to enable mod_proxy and mod_rewrite for this, and then do the following on ServerA:
<VirtualHost *:80>
<IfModule mod_proxy.c>
<IfModule mod_rewrite.c>
RewriteEngine On
rewriteCond %{HTTP_HOST} ^othersub\.mydomain\.com
rewriteRule (.*) http://192.168.6.108/$1 [P,L]
</IfModule>
</IfModule>
</VirtualHost>
This is untested, so i can't say that it will work 100%, but it's close... Have a look at Dynamic Mirror in the URL Rewriting Guide (http://httpd.apache.org/docs/2.0/misc/rewriteguide.html) (it's about half way down).
hope this leads you in the right direction..
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.