Host site on 2 servers - is this possible/easy/difficult?
Hi all I'd really appreciate any advice on this.
In Apache, is it possible to have www .domain.com hosted on 2 servers, such that requests say for www .domain.com/specialcontent/* are on server2, with everything else on server1?
I could do a redirect for the directory specialcontent/, but I want the URL to stay the same in the browser, i.e. always starting www .domain.com.
Any thoughts?? I'm hoping that some mod_rewrite smoke and mirrors or similar may do the trick, but I'm not (yet) that familiar with mod_rewrite and the like, and at the moment the documentation tends to give me a headache!
It is possible with mod_rewrite, but it would still require the browser to hit server1, server1 to redirect the request to server2, then server2 to return the content. It may be easier to use mod_proxy and just proxy the connections to server2 internally. You could also use squid and a custom redirector script to send /specialcontent to the other server. The easiest method to implement for this would be to just change the links pointing to /specialcontent so that they point to www2.domain.com (or media.domain.com, or whatever suits the content best). If you are redirecting that directory for load purposes, it may be best to set up DNS round-robin (where there are 2 A records for the same entry) to help ease load off server1 and onto server2. They won't be perfectly balanced but it won't be as bad as all the load on one server.
I should probably have said that the point of all this is to enable 2 parts of the site to be managed/hosted separately but to have them all appear to hang off the one webserver/domain root. Agreed that using a subdomain would be easiest - that's my fallback.
Can I just clarify ... as at times I rather wonder what on earth mod_rewrite actually does ...! ...:
would still require the browser to hit server1, server1 to redirect the request to server2, then server2 to return the content
How do I get server1 to redirect the request, and does it require the browser to process the redirect, in which case do we lose the main site's root URL?
mod_proxy also sounds promising - sounds like it will get server1 to request /specialpages... from server2 and then server1 returns the result to the browser?? I'll have a look at the doc. for this.
I know you can use mod_rewrite to rewrite the connection without changing the url, BUT i don't think that'll work across servers :/
It does sound like mod_proxy or squid would be best for you if you just want to have the two parts managed by separate entities while maintaining the same URL. Squid would be better as it is a stripped down daemon built to handle tons of connections really quickly. mod_proxy would tie up a connection within the apache server so you may run out of child processes should things get busy.
Matt Bloom AngryHosting - Load balanced/redundant shared hosting solutions
Yes subdomain would be easiest, and you could do this by changing the DNS settings of the domain on server #1 (Which would be referred to the parent server), and redirect that subdomain to server #2, which is also authoritive for that domain name (so that it responds).
Otherwise you could code something into your pages that will redirect the user to that server, there may even be some configurations for it in the apache configuration i can't quite remember. Google is your friend haha