Skip to content

Uses uptimerobot for monitoring, if a website is down, automatically switch the IP of an A record to a backup server's IP

Notifications You must be signed in to change notification settings

blackdotsh/UptimeFlare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 

Repository files navigation

UptimeFlare

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.



License: MIT
Dependencies: Web Server, PHP, php-curl lib

Setup:

  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 Cloudflare:
    if there's any client filtering in your API token settings, make sure you add your server's IP that's running this script to the whitelist.
  5. 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.
  6. 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 .

About

Uses uptimerobot for monitoring, if a website is down, automatically switch the IP of an A record to a backup server's IP

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages