Automatic message when server behind openwrt is down

Hi, I have my openwrt router some months in operation and wonder if a functionality described below would be possible.
There is a web server behind the router. The server is being accessed on its public name - port redirect (80 and 443) from internet and dnsmasq within the LAN.
Imagine the web server goes down (for example scheduled maintenance) - is it possible that in such a situation request to the server is being processed by the openwrt in a way that the client receives a message like "Server xxx is currently down, please try again in xx hours"?
I assume something like this:

  • a backup web server
  • a rule to redirect requests to the backup when server xxx is down, resp. not accessible
    Is it possible to configure such virtual backup web server within openwrt, i.e. on the router itself, and redirect to it?

I would imagine that you could script this. Don't use the OpenWrt web server (uhttpd) since it is not security hardened (it is intended to be light weight to run on embedded devices).

Your script could run on the OpenWrt router. Using wget or curl to attempt to get a page from your main web server would normally be successful. But when it fails (possibly a few times so you don't get spurious redirections), you could update the port-forwarding rule to send the traffic to a different host (maybe a RPi or something running sufficiently powerful to run a proper web server environment (i.e. for security purposes, not really necessary for bandwidth or back-end capabilities). The script would continue to monitor for the main web server and when it comes back online, the port-forwarding rules would be adjusted once again to direct to your main host.


Thanks for the answer and your recommendations!
This with using wget or curl didn't come to my mind at all

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.