google-cloud-platformnetwork-programminggoogle-cloud-networkinggcp-load-balancer

Routing traffic to specific VM's via load balancer on GCP


I am new to Google Cloud Platform and advanced networking in general but I have been tasked with setting up an external HTTPS load balancer that can forward internet traffic to 2 separate Virtual Machines on the same VPC. I have created the load balancer, SSL certs, DNS, frontend, and a backend. I have also created an instance group containing the two VM's for use with the backend.

What I am failing to understand is, how do I determine which VM is going to receive the traffic? Example:


Solution

  • To detail what @John Hanley mentioned in configuring URL maps, you can follow these steps :

    1. On you load balancer balancer page. Click the name of the load balancer, then look for Edit.
    2. Select Host and path rules, then click Add host and path rule.

    On the host field, enter test.com/login. Then for your path, instance1/some/path/login.php.

    1. Once done, for the Backends, select the backend associated to the VM instance. Do the same step for test.com/downloadby adding another host and path rule.
    2. Click Update.

    You can check and refer to this guide for more details