Forum Moderators: phranque

Message Too Old, No Replies

Apache --> How to setup httpd.conf virtual hosting to switch to a serv

         

JeffDrechsler

4:16 pm on Sep 14, 2007 (gmt 0)

10+ Year Member



Apache --> How to setup httpd.conf virtual hosting to switch to a server thats not responsive

I want to setup a system where I can either load balance my two apache servers. Or, at the very least, if the main server returns an HTTP 500 (JVM down), it should be smart enough to redirect to the same exact page using a different IP address. Is there a way to do that? If so, also, will it rewrite the url to contain the ip address or will it contain the domain name?

This is the code I've tried using in my httpd.conf virtual host block, but it doesnt seem to be doing anything. I just want to make sure Im doing this the correct way.

ErrorDocument 500 [myipaddress...]

[edited by: JeffDrechsler at 4:18 pm (utc) on Sep. 14, 2007]

jdMorgan

3:29 pm on Sep 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've thought about this for awhile, and the problem is that beyond ErrorDocument, it's not a good idea to introduce further dependencies into a server that's already got a problem. But perhaps something like this -- leaving out all the setup overhead and just outlining here:

ErrorDocument 500 /500errorurl.html
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(^\ )*\ HTTP/
RewriteRule ^/500errorurl\.html$ http://otherserverIPaddress/%1 [R=302,L]

Here, we use a virtual (non-existent) URL-path as the 500 ErrorDocument and then redirect that URL-path to the alternate server, using the original client request header to supply the client-requested URL-path to the alternate server.

However, if a serious problem exists that causes both the JVM and mod_rewrite to fail, this approach is not robust.

Jim