Google Cloud LB:更改 "server error" 默认 html 页面
Google Cloud LB: Change "server error" default html page
默认情况下,如果负载平衡无法找到将流量重定向到的后端,例如,如果所有可用的后端都已关闭,它会显示此 html 页面:
成绩单:
Error: Server Error
The server encountered a temporary error and could not complete your request.
Please try again in 30 seconds.
我想改用我自己的静态 html 页面。
我在 LB + 云存储页面上看到了这个 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.
那将如何运作?
我知道如何在云存储上托管静态页面,但我如何将它与 LB 一起使用?
简单地说,你不能,至少现在是这样。
您找到的 HTTP Load Balancer with Cloud Storage 处于 alpha 测试阶段,您需要申请白名单才能试用。但它不会解决你的问题。
因为到目前为止,还没有办法根据后端的响应手动控制负载均衡器的重定向。我认为这永远不可能。这不是 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.
以上语句仅表示您可以为存储桶中未找到的对象设置自定义 404 页面。如果您的后台服务已关闭 (502),这并不意味着让您重定向流量。两者之间有很大的区别:我找不到页面,因为我没有服务器,所以没有任何工作。
您只能将来自外部的流量重定向到网络内部。你不能做相反的事情。您不能要求负载均衡器根据响应进行重定向。
与其试图让 502 错误页面变得漂亮,不如问问自己为什么会出现它,然后尝试修复它。
默认情况下,如果负载平衡无法找到将流量重定向到的后端,例如,如果所有可用的后端都已关闭,它会显示此 html 页面:
成绩单:
Error: Server Error
The server encountered a temporary error and could not complete your request. Please try again in 30 seconds.
我想改用我自己的静态 html 页面。
我在 LB + 云存储页面上看到了这个 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.
那将如何运作? 我知道如何在云存储上托管静态页面,但我如何将它与 LB 一起使用?
简单地说,你不能,至少现在是这样。
您找到的 HTTP Load Balancer with Cloud Storage 处于 alpha 测试阶段,您需要申请白名单才能试用。但它不会解决你的问题。 因为到目前为止,还没有办法根据后端的响应手动控制负载均衡器的重定向。我认为这永远不可能。这不是 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.
以上语句仅表示您可以为存储桶中未找到的对象设置自定义 404 页面。如果您的后台服务已关闭 (502),这并不意味着让您重定向流量。两者之间有很大的区别:我找不到页面,因为我没有服务器,所以没有任何工作。
您只能将来自外部的流量重定向到网络内部。你不能做相反的事情。您不能要求负载均衡器根据响应进行重定向。
与其试图让 502 错误页面变得漂亮,不如问问自己为什么会出现它,然后尝试修复它。