4

We have a single-page web application deployed on a GCP bucket with a load balancer in front of it.
All URLs such as example.com/login should be rewritten as example.com/#/login. Without being rewritten the default behaviour is to go fetch some login.html but we only have and need index.html, the application handles the routing.

How to configure the load-balancer to achieve such a task?

Kyll
  • 141
  • 1
  • 5
  • 2
    Redirection on LB level is currently not possible on GCP. You may refer to [this](https://issuetracker.google.com/35904733) where some of the users have recommendations on how to redirect within the app. If this doesn’t help, you may file a [feature request](https://issuetracker.google.com/issues/new?component=187245&template=1010239) with the load balancing component using the [Google issue-tracking tool](https://developers.google.com/issue-tracker). – Faizan Aug 29 '18 at 00:40

2 Answers2

2

Google LB is capable of:

  • URL redirect
  • URL rewrite

based on URL prefixes since the summer 2020: https://cloud.google.com/load-balancing/docs/https/setting-up-traffic-management

Official blog announcement: https://cloud.google.com/blog/products/networking/how-to-use-new-traffic-control-features-in-cloud-load-balancing

Seems LB is primitive rewrite engine (only prefixes, no regex) so you cannot run SPA apps with LB, see https://stackoverflow.com/questions/72648022/deploy-spa-application-on-google-cloud-storage-using-load-balancer-and-cdn

UPDATE 2023 Actually it is possible to create SPA apps with GCP offer utilizing Bucket default 404 handler to index.html. See link above.

UPDATE2 2023 Google LB got capability to match against wildcard * (including recursive **): https://cloud.google.com/load-balancing/docs/url-map-concepts#wildcards-regx-dynamic-route

gavenkoa
  • 792
  • 8
  • 13
1

Redirection on LB level is currently not possible on GCP. You may refer to this where some of the users have recommendations on how to redirect within the app. If this doesn’t help, you may file a feature request with the load balancing component using the Google issue-tracking tool.

Wojtek_B
  • 1,013
  • 4
  • 14