My router forwards port 80 data to my Ubuntu Server box. I have another machine (Windows 7, running XAMPP) on my local network that is only sometimes on. Using a virtual host or otherwise, I wanted my Ubuntu box to forward data for a particular domain to the windows machine only when its on, and otherwise display a "Unavailable" page instead.

link|improve this question
feedback

3 Answers

I believe that your best bet would be to set up a bash script as a cron job. The basic logic would be:

  1. Ping Windows host
  2. If there is a response, update Apache (or other) to forward to the Windows box (mod_proxy comes to mind)
  3. If there is no response, update Apache to show an Unavailable page

Updating Apache can be as simple as changing the sites_enabled back and forth, once you have the proper sites set up.

link|improve this answer
feedback

You could use mod_proxy to do this quite simply.

<VirtualHost *:80>
     ProxyRequests Off
     DocumentRoot /var/www
    <Proxy *>
            Order deny,allow
            allow from all
    </Proxy>
    ProxyPreserveHost On
    ProxyPass / http://windows.machine/
    ProxyPassReverse / http://windows.machine/
    ProxyErrorOverride Off
</VirtualHost>

This will return a 503 Service Unavailable error when your windows box is off.

link|improve this answer
feedback

Setup a proxy config to the backend, make sure the timeouts are nice and low, and setup the error page that gets displayed on proxy timeout (504, from memory) to be your unavailable page.

10 minutes with the Apache manual should have you sorted for the exact configuration options to use.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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