Using Global Forwarding Rules

The global forwarding rule provides a single global IPv4 or IPv6 address that you can use in DNS records for your site. You can use more than one forwarding rule with a given proxy, so you can have one for IPv4 traffic and another for IPv6 traffic.

See the IPv6 Termination documentation for more information on supporting IPv6 addresses.

Global forwarding rule uses

Global forwarding rules route traffic by IP address, port, and protocol to a load balancing target proxy, which in turn forwards the traffic to an instance group containing your virtual machine instances.

Global forwarding rules can only be used with HTTP(S), SSL Proxy, and TCP Proxy load balancing configurations. For regional forwarding rules that can be used with regional load balancing and individual instances, see the protocol forwarding documentation.

Add, delete, describe, list, or update a global forwarding rule

You can use the Google Cloud Platform Console, the gcloud command-line tool, or the REST API, to create and modify global forwarding rules.

Add a global forwarding rule

Console

To add a new global forwarding rule using the GCP Console:

  1. Go to the Load balancing page.

    Go to the Load balancing page

  2. Click on the Edit pencil for a Load balancer
  3. Click Frontend Configuration.
  4. Click Add Frontend IP and port.
  5. Enter a Name.
  6. Select the Protocol.
    1. For http, select port number 80 or 8080.
    2. For https, select port number 443 is selected automatically and the field is grayed out. If you select https, select an existing SSL certificate or create a new one.
  7. Assign an existing static IP address, or create a new one.
  8. Click Done.
  9. Click Update.

gcloud: HTTP

To add a new global forwarding rule using the gcloud command-line tool, use the forwarding-rules create subcommand:

  gcloud compute forwarding-rules create [FORWARDING_RULE] \
    [--address [IP_ADDRESS]] \
    [--ip-protocol [IP_PROTOCOL]] \
    [--ports=[PORT | PORT-PORT],[[PORT | PORT-PORT],…]] \
      --global \
    [--ip-version [IP_VERSION]] \
    [--target-http-proxy [HTTP_PROXY]
      | --target-https-proxy [HTTPS_PROXY]
      | --target-ssl-proxy [SSL_PROXY]
      | --target-tcp-proxy [TCP_PROXY]]

API

To add a global forwarding rule using the API, send a POST request to the following URI:

  POST https://www.googleapis.com/compute/v1/projects/[PROJECT_ID]/global/forwardingRules

{ "name": [FORWARDING_RULE], "IPAddress": [IP_ADDRESS], "IPProtocol": [IP_PROTOCOL], "portRange": [PORT_RANGE], "ipVersion": IPV4 | IPV6, "target": [HTTP_PROXY] | [HTTPS_PROXY] | [SSL_PROXY] | [TCP_PROXY] }

List global forwarding rules

Console

To get a list of global forwarding rules using the GCP Console:

  1. Go to the Load balancing page.

    Go to the Load balancing page

  2. Select Frontends
  3. Sort by the Scope field to see all Global forwarding rules. The Load balancer field indicates the load balancer that uses a rule.

gcloud: HTTP

To get a list of global forwarding rules using the gcloud command-line tool, use the forwarding-rules list subcommand:

  gcloud compute forwarding-rules list --global
    [NAME_REGEX ...]
    [--limit LIMIT]
    [--raw-links]
    [--sort-by SORT_BY]
    [-l]
  

API

To get a list of global forwarding rules using the API, make an empty GET request to the following URI:

  https://www.googleapis.com/compute/v1/projects/[PROJECT_ID]/global/forwardingRules
  

Get information for a forwarding rule

Console

To get information about a single global forwarding rule using the GCP Console:

  1. Go to the Load balancing page.

    Go to the Load balancing page

  2. Select Frontends
  3. Sort by the Scope field to see all Global forwarding rules. The Load balancer field indicates the load balancer that uses a rule

gcloud: HTTP

To get information about a single global forwarding rule using the gcloud command-line tool, use the forwarding-rules describe subcommand:

  gcloud compute forwarding-rules describe [FORWARDING_RULE] --global
  

API

To get information about a single global forwarding rule using the API, make an empty GET request to the following URI:

https://www.googleapis.com/compute/v1/projects/[PROJECT_ID]/global/forwardingRules/[FORWARDING_RULE]

Update a global forwarding rule target

Console

To change the target proxy of an existing forwarding rule, use the GCP Console to perform the following tasks:

  1. Go to the Load balancing page.

    Go to the Load balancing page

  2. Under the list of load balancers, click Advanced menu.
  3. Click on the name of a global forwarding rule.
  4. Click the Edit pencil.
  5. In the Target pull-down menu, select the target proxy.
  6. Click Save. You can return to the Load balancing menu by clicking the left-facing arrow at the top of the screen.

gcloud: HTTP

To change the target proxy of an existing forwarding rule, use the forwarding-rules set-target sub-command:

  gcloud compute forwarding-rules set-target [FORWARDING_RULE] \
    --global \
      [--target-http-proxy [HTTP_PROXY]
      | --target-https-proxy [HTTPS_PROXY]
      | --target-ssl-proxy [SSL_PROXY]
      | --target-tcp-proxy [TCP_PROXY]]

API

In the API, send a POST request to the relevant URI, passing the name of the target proxy that you want to set in the request body:

POST https://www.googleapis.com/compute/v1/projects/[PROJECT_ID]/global/forwardingRules/[FORWARDING_RULE/setTarget

 {
   "target": [HTTP_PROXY] | [HTTPS_PROXY] | [SSL_PROXY] | [TCP_PROXY]
 }

Delete global forwarding rules

Console

To delete a global forwarding rule using the GCP Console:

  1. Go to the Load balancing page.

    Go to the Load balancing page

  2. Under the list of load balancers, click Advanced menu.
  3. Click the checkbox for each rule to delete.
  4. Click Delete.

gcloud: HTTP

To delete a global forwarding rule using the gcloud command-line tool, use the forwarding-rules delete sub-command:

  gcloud compute forwarding-rules delete [FORWARDING_RULE] --global [--quiet]

API

To delete a global forwarding rule from the API, send an empty DELETE request to:

https://www.googleapis.com/compute/v1/projects/[PROJECT_ID]/global/forwarding/forwardingRules/FORWARDING_RULE
Was this page helpful? Let us know how we did:

Send feedback about...

Load Balancing