So, this is the first time I'm actually asking for advice in internet instead of just searching for similar questions and answers.. be gentle :)

I want to setup my raspberry pi (raspbian os) to host a "lite" placeholder website, that gets replaced if another server running on my local network is online.

I have a debian box that I use mainly as a host for my personal website and as a dedicated game server.

The debian box takes quite a lot electricity and most of the time it's running idle. This is why I want to keep it powered off when it's not needed.

What I want to do is to make the raspberry show the user entering my website a placeholder page. From this placeholder page the user could the (through php-cgi-python) send a WOL-magic packet to the debian box. The debian box would then overtake handling the web requests coming from internet.

So. How do I make it so that when my debian box awakens, the user coming to my website won't see the site hosted in raspberry, but the site hosted in debian box? And the opposite: When the debian box gets shut down, the raspberry pi takes on hosting the website?

Some information about my setup:

*Both raspberry and debian are connected to my firewalled modem/router. I've port forwarded port 80 to Raspberry Pi.

*Raspberry Pi, running latest Raspbian OS

*Old server, running Debian GNU/Linux 8.6 (jessie)

  • You could also pose this question in the Raspberry Pi stack if you haven't already. Might have a better chance at an answer.
    – user565955
    Nov 18 '16 at 19:00
  • I thought of that, but I think this question isn't that much about the Raspberry Pi, but linux and networking in general. I might've empasized the Raspberry a bit too much.
    – Rytai
    Nov 20 '16 at 14:12

Consider setting up your Raspberry Pi as a caching server. A user requesting a cached page will be served from the Raspberry Pi. A request for an uncached page will be forwarded to your main server and served from there, waking it up in the process.

  • I haven't ever heard of this "cached server" term. After quick googling it looks really promising. Thanks. The next thing is to actually find information on how to create such a server on raspberry.
    – Rytai
    Nov 20 '16 at 14:05

I'm not 100% sure if this is possible, but one scenario that I can think of:

When someone queries the web page (your pi), your pi will check if your main server is up or down.

  • If down - put the "error message" telling user to wait and refresh the page (or you can set auto-refresh tag), and send WOL to the server.
  • If/when up, refresh the page and provide a redirection tag to your main server so they get the server main page.
  • A simple conditional redirection. Why didn't I think of that :) I'll try this method first. It's not the most elegant solution, but I think It'll work for now. I think I'll use javascript for the redirection and python+CGI for querying the other server's state.
    – Rytai
    Nov 20 '16 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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