11

By default, if the load balance can't find a backend to redirect traffic to, for example if all available backends are down, it shows this html page:

enter image description here

Transcript:

Error: Server Error

The server encountered a temporary error and could not complete your request. Please try again in 30 seconds.

I would like to use my own static html page instead.
I saw this on the LB + Cloud storage page here:

You can also configure a custom index page and a custom error page that will be served if the requested object doesn’t exist. This can be done by adding a Website Configuration to your Cloud Storage bucket. With a Website Configuration, you could serve a static webpage directly out of a Cloud Storage bucket from your own domain.

How would that work ? I know how to host static page on cloud storage, but how would I use it with the LB ?

Michael
  • 22,196
  • 33
  • 132
  • 187

1 Answers1

5

Simply put, you can't, at least for now.

The HTTP Load Balancer with Cloud Storage you found is in alpha, you will need to request a whitelist to try it. But it won't solve your problem. Because as of now, there is no way to control a load balancer's redirection manully based on the backends' responses. I don't think that will ever be possible. It's not the purpose of a load balancer in GCP.

You can also configure a custom index page and a custom error page that will be served if the requested object doesn’t exist.

The above statement only means that you can have a custom 404 page for unfound objects in the bucket. It's not meant to let you redirect traffic if your Back-services are down (502). There is a big difference between : I can't find a page, and Nothing is working because I don't have a server.

You can only redirect traffic coming from outside toward the inside of your network. You can't do the opposite. You can't ask the load balancer to redirect based on a response.

Instead of trying to make the 502 error page beautiful, ask yourself why you have it in the first place, and try to fix that.

Hakro
  • 2,625
  • 1
  • 12
  • 23
  • 3
    Thanks, I will take your word on it. Regarding your last comment - I disagree. There's no relation whatsoever between finding out why my website is down and making the error page less intimidating for our customers (beauty is not my aim here). I can actually do both! And regarding your opinion that this feature shouldn't exist, I also disagree. I'm not saying it's huge, just saying that I totally see why it's necessary. – Michael Dec 12 '16 at 13:43
  • I didn't mean that this feature shouldn't exist. It sure would be nice to have an option to redirect traffic if no backends are healthy. But I think it's logical that it doesn't. Kinda like it's normal to have an ugly 500 error if a single server is not responding, and we can't do much about it. But who knows, may be GCP will give us a nice solution soon :) – Hakro Dec 12 '16 at 14:31