I'm investigating a way of deploying an Angular or React web application on Google Cloud using GCS, Load Balancer, and CDN.
I've set up the LB and the GCS using the urlRewrite, but since the LB does not allow full URL rewrite only pathPrefixRewrite, I cannot redirect all the requests to /index.html
I want to achieve the same functionality as firebase hosting where you can specify the rewrite rules
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
Another option will be to set the 404 page as index.html, but that will result in a 404 status code return by the server, which I don't like.
Is this possible with Load Balancer, because they are not supporting a full rewrite?
It's now possible with the global external load balancer routing rules to rewrite every cloud storage request to serve the index.html.
defaultService: projects/xxxx/global/backendBuckets/dashboard
name: path-matcher-1
routeRules:
- matchRules:
- pathTemplateMatch: /**
priority: 10
service: projects/xxxx/global/backendBuckets/dashboard
routeAction:
urlRewrite:
pathTemplateRewrite: /index.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With