Google Cloud LB:更改“服务器错误”默认的html页面 [英] Google Cloud LB: Change "server error" default html page
问题描述
默认情况下,如果负载均衡无法找到后端来重定向流量,例如所有可用的后端都关闭,则会显示此html页面:
记录:
< h3>错误:服务器错误
服务器遇到临时错误,无法完成您的请求。
请在30秒后重试。
我想使用自己的静态html页面。
我在LB + Cloud存储页面上看到了这个:如果请求的对象不存在则被提供服务。这可以通过将网站配置添加到您的云存储存储桶来完成。通过网站配置,您可以直接从您自己的域中向云存储存储桶提供静态网页。
这将如何工作?
我知道如何在云存储上托管静态页面,但我如何使用它与LB?
带有云存储的HTTP负载均衡器您找到的是alpha,您需要请求白名单来尝试。但它不会解决你的问题。
因为目前为止,无法根据后端的响应来控制负载平衡器的重定向。我不认为这将是可能的。它不是GCP中负载均衡器的用途。
您还可以配置自定义索引页面和自定义错误页面如果请求的对象不存在。
以上声明仅意味着您可以为自定义404页面桶。如果您的后台服务关闭(502),它并不意味着让您重定向流量。有一个很大的区别:我找不到页面,没有任何工作,因为我没有服务器。
您只能重定向来自外部朝向您的网络内部。你不能做相反的事情。您不能要求负载平衡器根据响应进行重定向。
不要试图使502错误页面变得美观,问问自己为什么在第一个放置,并尝试解决这个问题。
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 ?
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.
这篇关于Google Cloud LB:更改“服务器错误”默认的html页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!