External proxy Network Load Balancer overview (original) (raw)

This document introduces the concepts that you need to understand to configure a Google Cloud external proxy Network Load Balancer.

The external proxy Network Load Balancer is a reverse proxy load balancer that distributes TCP traffic coming from the internet to virtual machine (VM) instances in your Google Cloud Virtual Private Cloud (VPC) network. When using an external proxy Network Load Balancer, incoming TCP or SSL traffic is terminated at the load balancer. A new connection then forwards traffic to the closest available backend by using either TCP or SSL (recommended). For more use cases, see Proxy Network Load Balancer overview.

External proxy Network Load Balancers let you use a single IP address for all users worldwide. The load balancer automatically routes traffic to the backends that are closest to the user.

In this example, SSL traffic from users in City A and City B is terminated at the load balancing layer, and a separate connection is established to the selected backend.

Cloud Load Balancing with SSL termination.

Cloud Load Balancing with SSL termination (click to enlarge).

Modes of operation

You can configure an external proxy Network Load Balancer in the following modes:

Identify the mode

To determine the mode of a load balancer, complete the following steps.

Console

  1. In the Google Cloud console, go to the Load balancing page.
    Go to Load balancing
  2. On the Load Balancers tab, the load balancer type, protocol, and region are displayed. If the region is blank, then the load balancer is global.
    The following table summarizes how to identify the mode of the load balancer.
    Load balancer mode Load balancer type Access type Region
    Classic proxy Network Load Balancer Network (Proxy classic) External
    Global external proxy Network Load Balancer Network (Proxy) External
    Regional external proxy Network Load Balancer Network (Proxy) External Specifies a region

gcloud

  1. Use the gcloud compute forwarding-rules describe command:
    gcloud compute forwarding-rules describe FORWARDING_RULE_NAME
  2. In the command output, check the load balancing scheme, region, and network tier. The following table summarizes how to identify the mode of the load balancer.
    Load balancer mode Load balancing scheme Forwarding rule Network tier
    Classic proxy Network Load Balancer EXTERNAL Global Standard or Premium
    Global external proxy Network Load Balancer EXTERNAL_MANAGED Global Premium
    Regional external proxy Network Load Balancer EXTERNAL_MANAGED Regional Standard or Premium

Architecture

The following diagrams show the components of external proxy Network Load Balancers.

Global

This diagram shows the components of a global external proxy Network Load Balancer deployment. This architecture applies to both the global external proxy Network Load Balancer and classic proxy Network Load Balancer in Premium Tier.

Global external proxy Network Load Balancer components.

Global external proxy Network Load Balancer components (click to enlarge).

Regional

This diagram shows the components of a regional external proxy Network Load Balancer deployment.

Regional external proxy Network Load Balancer components.

Regional external proxy Network Load Balancer components (click to enlarge).

The following are components of external proxy Network Load Balancers.

Proxy-only subnet

The proxy-only subnet provides a set of IP addresses that Google uses to run Envoy proxies on your behalf. You must create one proxy-only subnet in each region of a VPC network where you use load balancers. The --purpose flag for this proxy-only subnet is set to REGIONAL_MANAGED_PROXY. All regional Envoy-based load balancers in the same region and VPC network share a pool of Envoy proxies from the same proxy-only subnet.

Backend VMs or endpoints of all load balancers in a region and a VPC network receive connections from the proxy-only subnet.

Points to remember:

Forwarding rules and IP addresses

Forwarding rules route traffic by IP address, port, and protocol to a load balancing configuration that consists of a target proxy and a backend service.

IP address specification. Each forwarding rule references a single IP address that you can use in DNS records for your application. You can either reserve a static IP address that you can use or let Cloud Load Balancing assign one for you. We recommend that you reserve a static IP address. Otherwise, you must update your DNS record with the newly assigned ephemeral IP address whenever you delete a forwarding rule and create a new one.

Port specification. External forwarding rules used in the definition of this load balancer can reference exactly one port from 1-65535. If you want to support multiple consecutive ports, you need to configure multiple forwarding rules. Multiple forwarding rules can be configured with the same virtual IP address and different ports; therefore, you can proxy multiple applications with separate custom ports to the same TCP proxy virtual IP address. For more details, see Port specifications for forwarding rules.

To support multiple consecutive ports, you have to configure multiple forwarding rules. Multiple forwarding rules can be configured with the same virtual IP address and different ports. Therefore, you can proxy multiple applications with separate custom ports to the same TCP proxy virtual IP address.

The following table shows the forwarding rule requirements for external proxy Network Load Balancers.

Load balancer mode Network Service Tier Forwarding rule, IP address, and load balancing scheme Routing from the internet to the load balancer frontend
Classic proxy Network Load Balancer Premium Tier Global external forwarding rule Global external IP address Load balancing scheme: EXTERNAL Requests routed to the GFEs that are closest to the client on the internet.
Standard Tier Regional external forwarding rule Regional external IP address Load balancing scheme: EXTERNAL Requests routed to a GFE in the load balancer's region.
Global external proxy Network Load Balancer Premium Tier Global external forwarding rule Global external IP address Load balancing scheme: EXTERNAL_MANAGED Requests routed to the GFEs that are closest to the client on the internet.
Regional external proxy Network Load Balancer Premiumand Standard Tier Regional external forwarding rule Regional external IP address Load balancing scheme: EXTERNAL_MANAGED Requests routed to the Envoy proxies in the same region as the load balancer.

Forwarding rules and VPC networks

This section describes how forwarding rules used by external Application Load Balancers are associated with VPC networks.

Load balancer mode VPC network association
Global external proxy Network Load Balancer Classic proxy Network Load Balancer No associated VPC network. The forwarding rule always uses anIP address that is outside the VPC network. Therefore, the forwarding rule has no associated VPC network.
Regional external proxy Network Load Balancer The forwarding rule's VPC network is the network where the proxy-only subnet has been created. You specify the network when you create the forwarding rule. Depending on whether you use an IPv4 address or an IPv6 address range, there is always an explicit or implicit VPC network associated with the forwarding rule. Regional external IPv4 addresses always exist outside of VPC networks. However, when you create the forwarding rule, you're required to specify the VPC network where the proxy-only subnet has been created. Hence, the forwarding rule has an explicit network association. Regional external IPv6 address ranges always exist inside a VPC network. When you create the forwarding rule, you're required to specify the subnet from which the IP address range is taken. This subnet must be in the same region and VPC network where a proxy-only subnet has been created. Thus, there is an implied network association. Network and subnet requirements. For IPv6 traffic, your network and subnets must meet the following configuration requirements: VPC network: you must use a custom mode VPC network configured with the--enable-ula-internal-ipv6 flag. Forwarding rule subnet: this subnet must be a dual-stack (IPv4_IPv6) or IPV6_ONLY subnet with the ipv6-access-type set toEXTERNAL. IPv6 address allocation options. The forwarding rule must reference a /96 range of IPv6 addresses from the subnet's /64 external IPv6 address range. You can assign this /96 IPv6 address range using one of the following methods: Specifying a reserved external IPv6 address. Specifying a custom ephemeral IPv6 address. Letting Google Cloud automatically assign an ephemeral IPv6 address. Limitations. To specify a custom ephemeral IPv6 address, you must use the Google Cloud CLI or the API. The Google Cloud console doesn't support specifying custom ephemeral IPv6 addresses for forwarding rules.

Target proxies

External proxy Network Load Balancers terminate connections from the client and create new connections to the backends. The target proxy routes these new connections to the backend service.

Depending on the type of traffic your application needs to handle, you can configure an external proxy Network Load Balancer with either a target TCP proxy or a target SSL proxy.

By default, the target proxy does not preserve the original client IP address and port information. You can preserve this information by enabling the PROXY protocol on the target proxy.

The following table shows the target proxy requirements for external proxy Network Load Balancers.

Load balancer mode Network Service Tier Target proxy Reference
Classic proxy Network Load Balancer Premium Tier targetTcpProxies or targetSslProxies Target proxy references a single backend service.
Standard Tier targetTcpProxies or targetSslProxies
Global external proxy Network Load Balancer Premium Tier targetTcpProxies or targetSslProxies Target proxy references a single backend service.
Regional external proxy Network Load Balancer Premium and Standard Tier regionTargetTcpProxies Target proxy references either a single backend service or one or more TLS routes.

SSL certificates

SSL certificates are only required if you're deploying a global external proxy Network Load Balancer and classic proxy Network Load Balancer with a target SSL proxy.

External proxy Network Load Balancers using target SSL proxies require private keys and SSL certificates as part of the load balancer configuration.

TLS routes

A TLS routeresource lets you define how traffic is routed to backend services based on SNI hostnames.

If the load balancer's target TCP proxy is not referenced by a TLS route, then only the single default backend service is used, and the value of SNI hostname sent by the client or its absence isn't relevant.

TLS routes are only available for regional external proxy Network Load Balancers. They aren't supported for classic proxy Network Load Balancers and global external proxy Network Load Balancers.

You can attach a TLS route configuration to a load balancer's target proxy by using the gcloud network-services tls-routescommands.

The following table shows the TLS routes APIs required by external proxy Network Load Balancers:

Load balancer mode TLS route Reference
Regional external proxy Network Load Balancer Regional tlsRoutes Each TLS route can reference one or more backend services.

Backend services

Backend services direct incoming traffic to one or more attached backends. Each backend is composed of aninstance group ornetwork endpoint group and information about the backend's serving capacity. Backend serving capacity can be based on CPU or requests per second (RPS).

Each load balancer has at least one backend service resource. If you use TLS routes (Preview) to configure routing, you can configure multiple backend services for your load balancer. Without TLS routes, you're limited to only a single backend service per load balancer.

The backend service specifies the health check to be performed for the available backends.

Changes made to the backend service are not instantaneous. It can take several minutes for changes to propagate to GFEs. To ensure minimal interruptions to your users, you can enable connection draining on backend services. Such interruptions might happen when a backend is terminated, removed manually, or removed by an autoscaler. To learn more about using connection draining to minimize service interruptions, seeEnabling connection draining.

For more information about the backend service resource, seeBackend services overview.

The following table specifies the different backends supported on the backend service of external proxy Network Load Balancers.

Load balancer mode Supported backends on a backend service
Instance groups Zonal NEGs Internet NEGs Serverless NEGs Hybrid NEGs Private Service Connect NEGs GKE
Classic proxy Network Load Balancer Use standalone zonal NEGs
Global external proxy Network Load Balancer * GCE_VM_IP_PORT type endpoints *
Regional external proxy Network Load Balancer GCE_VM_IP_PORT type endpoints Regional NEGs only Add a Private Service Connect NEG

* Global external proxy Network Load Balancers support IPv4 and IPv6 (dual stack) instance groups and zonal NEG backends with GCE_VM_IP_PORT endpoints.

Backends and VPC networks

For global external proxy Network Load Balancer and classic proxy Network Load Balancer backends, all backend instances from instance group backends and all backend endpoints from NEG backends must be located in the same project. However, an instance group backend or a NEG can use a different VPC network in that project. The different VPC networks don't need to be connected using VPC Network Peering because GFEs communicate directly with backends in their respective VPC networks.

For regional external proxy Network Load Balancer backends, the following applies:

Backends and network interfaces

If you use instance group backends, packets are always delivered to nic0. If you want to send packets to non-nic0 interfaces (either vNICs or Dynamic Network Interfaces), use NEG backends instead.

If you use zonal NEG backends, packets are sent to whatever network interface is represented by the endpoint in the NEG. The NEG endpoints must be in the same VPC network as the NEG's explicitly defined VPC network.

Protocol for communicating with the backends

When you configure a backend service for an external proxy Network Load Balancer, you set the protocol that the backend service uses to communicate with the backends.

The load balancer uses only the protocol that you specify, and does not attempt to negotiate a connection with the other protocol.

Firewall rules

The following firewall rules are required:

Firewall rules are implemented at the VM instance level, not at the GFE proxies level. You cannot use firewall rules to prevent traffic from reaching the load balancer.

The ports for these firewall rules must be configured as follows:

The following table summarizes the required source IP address ranges for the firewall rules.

Load balancer mode Health check source ranges Request source ranges
Global external proxy Network Load Balancer 35.191.0.0/16 130.211.0.0/22 For IPv6 traffic to the backends: 2600:2d00:1:b029::/64 The source of GFE traffic depends on the backend type: Instance groups and zonal NEGs (GCE_VM_IP_PORT): 130.211.0.0/22 35.191.0.0/16 For IPv6 traffic to the backends: 2600:2d00:1:1::/64
Classic proxy Network Load Balancer 35.191.0.0/16 130.211.0.0/22 These ranges apply to health check probes and requests from the GFE.
Regional external proxy Network Load Balancer *, † 35.191.0.0/16 130.211.0.0/22 For IPv6 traffic to the backends: 2600:2d00:1:b029::/64 These ranges apply to health checks probes.

*Allowing traffic from Google's health check probe ranges isn't required for hybrid NEGs. However, if you're using a combination of hybrid and zonal NEGs in a single backend service, you need to allow traffic from the Google health check probe ranges for the zonal NEGs.

†For regional internet NEGs, health checks are optional. Traffic from load balancers using regional internet NEGs originates from the proxy-only subnet and is then NAT-translated (by using Cloud NAT) to either manually or automatically allocated NAT IP addresses. This traffic includes both health check probes and user requests from the load balancer to the backends. For details, see Regional NEGs: Use a Cloud NAT gateway.

Source IP addresses

The source IP address for packets, as seen by the backends, is not the Google Cloud external IP address of the load balancer. In other words, there are two TCP connections.

For the classic proxy Network Load Balancers and global external proxy Network Load Balancers:

For the regional external proxy Network Load Balancers:

Open ports

External proxy Network Load Balancers are reverse proxy load balancers. The load balancer terminates incoming connections, and then opens new connections from the load balancer to the backends. These load balancers are implemented by using Google Front End (GFE) proxies worldwide.

GFEs have several open ports to support other Google services that run on the same architecture. When you run a port scan, you might see other open ports for other Google services running on GFEs.

Running a port scan on the IP address of a GFE-based load balancer isn't useful from an auditing perspective for the following reasons:

With that in mind, the following are some more effective ways to audit the security of your backend instances:

Regional external proxy Network Load Balancers and classic proxy Network Load Balancers support deployments that use Shared VPC networks. Shared VPC lets you maintain a clear separation of responsibilities between network administrators and service developers. Your development teams can focus on building services in service projects, and the network infrastructure teams can provision and administer load balancing. If you're not already familiar with Shared VPC, read theShared VPC overview documentation.

IP address Forwarding rule Target proxy Backend components
An external IP address must be defined in the same project as the load balancer. The external forwarding rule must be defined in the same project as the backend instances (the service project). The target TCP or SSL proxy must be defined in the same project as the backend instances. For classic proxy Network Load Balancers, a global backend service must be defined in the same project as the backend instances. These instances must be in instance groups attached to the backend service as backends. Health checks associated with backend services must be defined in the same project as the backend service. For regional external proxy Network Load Balancers, the backend VMs are typically located in a service project. A regional backend service and health check must be defined in that service project.

Traffic distribution

When you add a backend instance group or NEG to a backend service, you specify aload balancing mode, which defines a method that measures the backend load and target capacity.

For external proxy Network Load Balancers, the balancing mode can be CONNECTIONor UTILIZATION:

The distribution of traffic across backends is determined by the balancing mode of the load balancer.

Classic proxy Network Load Balancer

For the classic proxy Network Load Balancer, the balancing mode is used to select the most favorable backend (instance group or NEG). Traffic is then distributed in a round robin fashion among instances or endpoints within the backend.

How connections are distributed

A classic proxy Network Load Balancer can be configured as a global load balancing service with Premium Tier, and as a regional service in the Standard Tier.

The balancing mode and choice of target determine backend fullness from the perspective of each zonal GCE_VM_IP_PORT NEG, zonal instance group, or zone of a regional instance group. Traffic is then distributed within a zone by using consistent hashing.

For Premium Tier

For Standard Tier

Global external proxy Network Load Balancer

For the global external proxy Network Load Balancer, traffic distribution is based on the load balancing mode and the load balancing locality policy.

The balancing mode determines the weight and fraction of traffic to be sent to each group (instance group or NEG). The load balancing locality policy (LocalityLbPolicy) determines how backends within the group are load balanced.

When a backend service receives traffic, it first directs traffic to a backend (instance group or NEG) according to the backend's balancing mode. After a backend is selected, traffic is then distributed among instances or endpoints in that backend group according to the load balancing locality policy.

For more information, see the following:

How connections are distributed

A global external proxy Network Load Balancer can be configured as a global load balancing service with Premium Tier

The balancing mode and choice of target determine backend fullness from the perspective of each zonal GCE_VM_IP_PORT NEG, or zonal instance group. Traffic is then distributed within a zone by using consistent hashing.

Regional external proxy Network Load Balancer

For regional external proxy Network Load Balancers, traffic distribution is based on the load balancing mode and the load balancing locality policy.

The balancing mode determines the weight and fraction of traffic that should be sent to each backend (instance group or NEG). The load balancing locality policy (LocalityLbPolicy) determines how backends within the group are load balanced.

When a backend service receives traffic, it first directs traffic to a backend (instance group or NEG) according to its balancing mode. After a backend is selected, traffic is then distributed among instances or endpoints in that backend group according to the load balancing locality policy.

For more information, see the following:

SNI-based routing with TLS routes

SNI-based routing lets your TCP proxy Network Load Balancers route traffic to specific backend services based on the Server Name Indication (SNI) hostname provided during the TLS handshake. SNI is a TLS extension that allows a client to specify the domain name it wants to reach before the encrypted tunnel is established. The SNI hostname is transmitted in an unencrypted format within the ClientHellomessage so that the load balancer can inspect this value and route traffic to the appropriate backend service.

You can use a TLS route configuration resource to map specific SNI hostnames to backend services. When SNI-based routing is configured, the load balancer enables TLS passthrough, where the encrypted byte stream is passed directly to the backend without being decrypted by the load balancer.

This feature unlocks some key use-cases such as:

How traffic is distributed when TLS routes are used

When SNI-based routing is configured, traffic is routed to backend services as follows:

  1. The load balancer listens on the IP and port defined in the forwarding rule.
  2. When a client initiates a TLS connection, the load balancer intercepts theClientHello message and extracts the SNI hostname.
  3. The extracted SNI is compared against the hostnames defined in the configured TLS routes. The load balancer uses the following logic to determine which backend service should receive the traffic:
    1. If the client does not use the TLS protocol, the load balancer closes the connection.
    2. If the client does not send any SNI hostname name in its ClientHellomessage, the load balancer closes the connection.
    3. If the client sends an SNI hostname that is not a valid DNS name, the load balancer closes the connection.
    4. If the client sends an SNI hostname that doesn't match any SNI hostnames associated with a TLS route, the load balancer closes the connection.
    5. In all other situations: The load balancer selects a backend service using the following matching process:
      Matching is done by the longest suffix (longest in terms of the number of subdomains). To illustrate the matching method, consider a TLS route whose SNI is *.foo.com, another TLS route whose SNI is *.bar.foo.com, and the third TLS route whose SNI is baz.bar.foo.com.
      • If the client's SNI hostname is baz.bar.foo.com, the load balancer selects a backend service which is referenced by the TLS route whose SNI is baz.bar.foo.com.
      • If the client's SNI hostname is qux.bar.foo.com, the load balancer selects a backend service which is referenced by the TLS route whose SNI is *.bar.foo.com.
      • If the client's SNI hostname is qux.qux.foo.com, the load balancer selects a backend service which is referenced by the TLS route whose SNI is *.foo.com.

Once a match is found, the encrypted byte stream is proxied directly to the assigned backend service without terminating the TLS connection (for TLS passthrough).

Limitations

The following limitations apply when you use TLS routes to configure SNI-based routing:

Session affinity

Session affinity lets you configure the load balancer's backend service to send all requests from the same client to the same backend, as long as the backend is healthy and has capacity.

External proxy Network Load Balancers offer the following types of session affinity:

Keep the following in mind when configuring session affinity:

Losing session affinity

All session affinity options require the following:

All session affinity options have the following additional requirements:

Failover

Failover for external proxy Network Load Balancers works as follows:

Load balancing for GKE applications

If you are building applications in Google Kubernetes Engine, you can use standalone NEGs to load balance traffic directly to containers. With standalone NEGs, you are responsible for creating theService object that creates the NEG, and then associating the NEG with the backend service so that the load balancer can connect to the Pods.

For related documentation, see Container-native load balancing through standalone zonal NEGs.

Limitations

What's next