ILB - How to call URL from header?

I am looking for some dynamic configuration via which the ILB can start calling any URL I passed in some header.

I am trying to handle multiple URLs calls from single PSC connection.

I am planning to call PSC endpoint with required URL in some header. The attachment is to ILB where I want this header to be read and redirect request to the same.

2 4 109
4 REPLIES 4

Hi @amitkhosla ,

Based from what you're saying, it looks like you wanted to set up a system where the ILB checks a special header in incoming requests. The ILB would then use the URL mentioned in that header to send the request to the right backend service.

Here is the general approach for it. Basically, configure ILB, then create and configure backend service and health check for it. And then, you will need to set up header-based routing, which determines which backend service should handle the request based on the extracted URL information. This could involve maintaining a mapping between URLs and backend services.

The command should like the example below (Assuming you have Nginx or another reverse proxy that can handle header-based routing):

# Nginx configuration snippet
server {
listen 80;
server_name my-internal-lb-ip;

location / {
proxy_pass http://$http_x_url;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

 When you send requests to your Internal Load Balancer, just add a header, for example, X-URL: backend-service-url. This helps specify which backend service you want to use.

Let me know if you find this helpful.

In addition, this community discussion may be helpful as it can be related to your concern. 

I think, in the link shared, the ask is to add header, but my requirement here is to route based on the header.

Thanks!! This is the plan I was also having, i.e., resolve via Nginx. But am exploring any option where I can have it done via google ILB itself so that don't need to manage another component(nginx).