1

I need to create the following rules in Google cloud load balancer:

  1. /en/example
  2. /ar/example
  3. /.../example

Such as the 2 letters represents a locale.

I couldn't find a way to setup regular expressions in the load-balancer url-map. How could this be achieved?

asker asky
  • 11
  • 2

2 Answers2

0

I was able to create fallowing environment:

Domain: example.com Three buckets: www.example.com, example-en and example-ar. All three publicly accessible for read;

  • www.example.com contains index.html file in the main directory
  • example-en contains index.html file in the /en/ directory
  • example-ar contains index.html file in the /ar/ directory

Each bucket required setting up index page to work:

gsutil web set -m index.html gs://www.example.com/
Setting website configuration on gs://www.example.com/...
gsutil web set -m index.html gs://example.en/
Setting website configuration on gs://example.en/...
gsutil web set -m index.html gs://example.ar/
Setting website configuration on gs://example.ar/...

I configured HTTPTS load balancer (with GCP's managed SSL certificate) for example.com and 'www.example.com`.

  • Backend services & backend buckets contain three above buckets.
  • Host and path rules are configured that:

You can redirect any path to any bucket you want, the only requirement is that the redirected path must match the path in the bucket (otherwise it won't work). You can also use subdomains and redirect them to other buckets. It's possible to add new services and paths to existing LB so you can make changes later on.

Let me know if this answers your question.

Last thing is setting up a front-end (one for port 80 and one for 443 with SSL encryption).

You can also have a look at the Path Matcher documentation which will give you some more ideas.

Wojtek_B
  • 4,245
  • 1
  • 7
  • 21
0

Regex is not available in GLB at this time We can only use path based request route to the backend services(instance group / bucket)

Reference: Path rules do not use regular expression or substring matching.

Source: https://cloud.google.com/load-balancing/docs/url-map-concepts#pm-constraints

IrfanM
  • 11
  • 2