In GCP, I am running three NodeJS APIs in a single instance with three different port numbers (3000, 3001, and 3002), and I created an external application load balancer using the HTTPS front end. I also created a backend service for the three port numbers. The load balancer is attached to the instance group.
If I am requesting the URL "https://example.com/" reaching port 3000 This is working well for me for the single-backend service. but I need to pass this same URL, "https://example.com/" with different HTTP headers and values. For example, if I request the URL "https://example.com/" port 3000 needs to be reached, but if I request the same URL "https://example.com/" with the "mydealsapi" HTTP headers, port 3001 needs to be reached, and again, if I request the same URL "https://example.com/" with the "appapi" HTTP headers, port 3002 needs to be reached.
You need to use forwarding rules in Google Cloud. It depends on if you have a global or regional load balancer what you have available. But you can create forwarding rules that route traffic to a specific port.
Here are the docs for more info: https://cloud.google.com/load-balancing/docs/forwarding-rule-concepts#external_fr
You can create forwarding rules through the GC console or you can create them using the gcloud cli using the
gcloud compute forwarding-rules create
Depending on the load blancer type, you can use ths "--ports==" flag.
Here is a doc for that: https://cloud.google.com/sdk/gcloud/reference/compute/forwarding-rules/create
Note: Port specification requirements vary depending on the load-balancing scheme and target. For more information, refer to https://cloud.google.com/load-balancing/docs/forwarding-rule-concepts#port_specifications.