Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud Load balancer URL Rewrite not working

I'm trying to setup google cloud load-balancer with HTTPS proxy. The rewrite rules doesn't seem to work. I've attached a screenshot of the same. Any help is appreciated.

enter image description here

Basically I'm trying to access <domain>/api/ping on <domain>/ping. Not sure what the Host rewrite is about as well.

Thanks in advance.

like image 423
sowdri Avatar asked Jul 27 '20 10:07

sowdri


People also ask

How do I know if URL rewrite is working?

Checking if the URL Rewrite module is installed To see if the URL Rewrite module is installed, open IIS Manager and look in the IIS group - if the module is installed, an icon named URL Rewrite will be present. The screenshot below shows an example of a server when the module is installed.

Does the URL in the browser change when a rewrite happens?

Fiddler is a great tool to see the back and forth between the browser and server. Tools like Process Monitor and native IIS tools are best for getting under the covers. A rewrite doesn't change the URL in the browser, but it does change the URL before the request is fully processed by IIS.

What is a URL rewrite rule?

A rewrite rule defines the logic of what to compare or match the request URL with, and what to do if the comparison is successful. Rewrite rules consists of the following parts: Pattern – The rule pattern is used to specify either the regular expression or a wildcard pattern that is used to match URL strings.


1 Answers

I think the problem is that (at the moment) GCP Load Balancers rewrite is only a "path prefix" rewrite, not a full rewrite, i.e. it prepends the value of the "path prefix rewrite" onto the original request URL.

So I suspect what you have currently is resulting in a request to restoplus-api-backend-services with a URL of /api/ping/ping.

If you set the value of "path prefix rewrite" to /api, you should get a request to your backend of /api/ping.

like image 185
Ieuan Avatar answered Sep 29 '22 09:09

Ieuan