A PHP web hook to handle down notifications from uptimerobot. If a DOWN notification is received, it'll change the A record of a domain on cloudflare to a backup IP set by you.
Dependencies: Web Server, PHP, php-curl lib
1. I suggest you rename the php file to something obscure.
2. Add / change the global vars section. It consists of credentials and other information that needs to be modified to your needs.
3. Upload this script to the desired server, make sure the script is accessible via the internet.
4. On uptimeRobot:
Create a new alert contact and select web hook. For url, put in the url to the php script and add "?key=YourKeySetInThePHPScript&".
If my $key was set to HelloWorld and I renamed my script to monitorUP.php which is accessible via 127.0.0.1, then for the url I would put
http://127.0.0.1/monitorUP.php?key=HelloWorld& Make sure you have the & at the end.
5. Add this alert type to your websites. It's recommended that you have more than the PHP hook as an alert type (such as email notification), so you can switch it back to the primary server once it's up. This should be done manually (login to cloudflare and change the IP) because there might be inconsistencies between the primary and the backup server, which requires manual intervention.
With this setup, a website shouldn't have a downtime of more than ~6 minutes, assuming your DNS provider does not cache queries.
You can reach me on twitter .
If you're looking for StatusCake + Cloudflare, you can find it here .