Google Cloud LB: Change “server error” default html page

安稳与你 提交于 2019-12-12 10:48:16

问题


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:

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 ?


回答1:


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.



来源:https://stackoverflow.com/questions/40701460/google-cloud-lb-change-server-error-default-html-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!