1

Let's say we have two Google Cloud instances, how can we configure a load balancer to route traffic to one of these VMs, based on the client IP?

As stated in the official documentation (https://cloud.google.com/load-balancing/docs/https/traffic-management), external HTTP(S) Load Balancing supports advanced traffic management functionality that enables you to route traffic with header-based and parameter-based routing, and the client IP is available in the header (Getting Orgin IP From Load Balancer), but there are no clear examples for this.

Below an example of the flow:

exampleflow

z3d0
  • 413
  • 5
  • 12

2 Answers2

0

create a http(s) Load balancer and specify those client address in the target IP address session after you have select ipv4 type. do this for both vms. you can also try using a router to route traffic to the instances. hope this helps. i dont have a documentation for this. i have done something like this in the past

0

It’s easy to configure instances to redirect traffic based on IP addresses but, since you asked for redirection on the load balancer level then you should configure the load balancer itself. It’s better to configure GCE instances to serve only particular IP’s and the load balancer can be configured with default values. Still if you want to configure a load balancer then you need to check ingress firewall rules and forwarding rules. Please follow the steps from the documentation provided.