How to Bypass a CDN When Monitoring Site Uptime

StackPath

So you have some websites sitting behind a CDN, and you want to use a service like UptimeRobot or Uptime Kuma to track and alert you if something goes wrong. In most cases, these services are pretty straight forward and easy to set up. However, your content delivery network could throw a small wrench into the gears if you are not careful.

The Problem

I was recently setting up Uptime Kuma on a server of mine, when I came across this issue.

In order to test the notification settings, I simulated a WordPress "Database Error" by changing the db credentials in the config file. What I expected to see was a bunch of notices coming across on Slack and my phone telling me the site was down.

However, nothing happened.

The initial assumption was the "Database Error" page was still signaling a 200 page code, which Uptime Kuma would interpret as an ALL CLEAR sign. After verifying it was showing as a 500, I was perplexed.

CDN Keeps Serving Files

It wasn't until I switched to an incognito browser that I saw what was going on. On the new browser the page loaded right up. The CDN was serving the files, despite the origin server being down. This was great from a user experience perspective, but counterproductive when looking for real-time status updates.

Bypass the CDN

I spent more time than I care to admit looking for a generic work around. I use multiple CDN companies, so my initial search was focused on a one-size-fits-all solution. In addition, I wanted to find the simplest process since I would need to deploy and manage it on many different web properties.

Unfortunately, I didn't find an elegant fix that would work across the board, but I did ultimately find quick fixes for the specific CDNs in question.

Rocket CDN

A favorite among WordPress developers, Rocket has a very simple solution to bypassing the CDN:

?nowprocket

Simply append that to the end of any URL and the Rocket CDN will be completely bypassed. So if you are wanting to monitor your homepage, use https://DOMAIN.com?nowprocket.

StackPath

If you are using StackPath for your CDN, you can add an EdgeRule that allows you to bypass it altogether. Here is a basic configuration you can use for uptime monitoring. If you have further use cases, StackPath provides a robust condition set to meet just about any need:

StackPath CDN

If you are looking for this solution on a different CDN and can't find one, drop a comment or contact me. I'll help you find one.

Gravatar

Don't take my word for it. I'm just a random guy on the internet.