我正在研究一种使用GCS、Load Balancer和CDN在Google上部署角度或响应web应用程序的方法。
我已经使用pathPrefixRewrite,设置了LB和GCS,但由于LB不允许完全重写urlRewrite,所以不能将所有请求重定向到/index.html
我希望实现与防火墙托管相同的功能,在这里您可以指定重写规则。
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]另一种选择是将404页设置为index.html,但这将导致服务器返回404 status code,我不喜欢这样做。
对于负载均衡器来说,这是可能的,因为它们不支持完全重写吗?
发布于 2022-10-20 09:47:52
谷歌在2020年增加了重写引擎(参见https://serverfault.com/questions/927143/how-to-manage-url-rewrites-with-a-gcp-load-balancer/1045214),它只有pathPrefixRewrite (去掉固定前缀)。
对于SPA,需要变量后缀重写到index.html,所以使用Nginx或Firebase。
或者提到了bucket的HTTP服务器中的错误处理程序(对于虚拟URL,HTTP代码404的缺点是):
gsutil web set -m index.html -e index.html gs://web-stage/设置SPA应用程序的完整说明如下:Google cloud load balancer create backend service for Firebase Hosting to serve microservices & frontend SPA from the same domain via load balancer?
LB重写引擎限制的讨论:
https://stackoverflow.com/questions/72648022
复制相似问题