1

In gcp load balancer. I have this rule:

HOST: *

Paths: /test/*

backend: test-server-backend-bucket

test-server-backend-bucket is bind to a cloud storage bucket test-server. But in test-server, there is no test folder, only files. I can't change the paths and create test folder in the test-server due to some limitation.

Hoping to get files in test-server using url like this http://[ip]/test/test1.txt

Is there someway that I can achieve this in GCP?

PotatoBeans
  • 11
  • 1
  • 2

3 Answers3

0

I'm not seeing the value of putting Google Cloud Storage (GCS) access behind a load balancer. Rather, I would imagine that if one wanted to access GCS objects as URLs one would point to those directly.

Imagine your company has the domain name example.com. Then you might associate your back-end services which are accessible through load balancers with the address record in DNS which maps:

services.example.com -> Static public IP of load balancer.

Now let us imagine you create a bucket in GCS called mydata.example.com. By adding a CNAME record in DNS (see https://cloud.google.com/storage/docs/request-endpoints) you could then access files in the bucket as:

http://mydata.example.com/test1.txt

This wouldn't go anywhere near a load balancer and can take advantage of GCS distributed data including CDN.

Kolban
  • 13,794
  • 3
  • 38
  • 60
  • Sorry. I don't think this is the solution – PotatoBeans Oct 24 '19 at 22:13
  • I need to access the object in this way http://mydata.example.com/test/test1.txt – PotatoBeans Oct 24 '19 at 22:14
  • Can you elaborate on the idea of not being able to change the URL path to mydata.example.com/test1.txt or not creating a folder called test in the bucket called mydata.example.com. I think we agree that either of those would solve the issue. I'm pretty sure you have a good reason for not being able to use these but I'm wondering what it might be? I wonder if a symbolic link was available but no ... https://stackoverflow.com/questions/12564669/an-object-in-google-cloud-storage-which-acts-as-a-redirect-or-symlink – Kolban Oct 24 '19 at 22:28
  • Kolban, Thanks for your help! These limitations are due to some other projects that I can't change. I just want to find out if GCP has some flexible way to do that. Looks like symbolic link is not supported.. – PotatoBeans Oct 24 '19 at 22:53
  • But this will be http only,or you should buy multi-domain ssl which is quite expensive. – london_utku Dec 23 '21 at 17:11
  • Access via a LB can be customized in different ways, e.g. CloudArmor policies. – Jokester Apr 20 '23 at 07:53
0

The loadbalancer don't allow you to perform URL rewriting.

The DNS and CNAME solution of Kolban is the right one for a minimizing the Storage operation.

guillaume blaquiere
  • 66,369
  • 2
  • 47
  • 76
0

You can use the Advanced host and path rule (URL redirect, URL rewrite) option:

host and path rules

Then add your bucket here:

enter image description here

RiveN
  • 2,595
  • 11
  • 13
  • 26