How to force Fastly CDN to redirect requests to a seperate domain if the user receives 50* errors?

1.2k views Asked by At

We want to force users to view our Status Page hosted on a subdomain when our Fastly CDN receives a 50* error from the back end origin?

Can someone provide any assistance, we have read these two articles but it's above our head:

https://docs.fastly.com/en/guides/creating-error-pages-with-custom-responses#creating-custom-responses-using-vcl-snippets

https://docs.fastly.com/en/guides/custom-responses-that-dont-hit-origin-servers

1

There are 1 answers

0
Kailan Blanks On

The Fastly Developer Hub has a recipe for replacing origin errors with your own responses: https://developer.fastly.com/solutions/recipes/replace-origin-errors-with--safe--responses

You can easily modify this to return a 301 instead to redirect the user to your own status page as demonstrated in this Fiddle: https://fiddle.fastlydemo.net/fiddle/937547c8

This VCL can be implemented in your own service via VCL Snippets in the Fastly UI.