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 gcloud command-line tool, the REST API, or the Google Cloud Platform Console to create and modify global forwarding rules.

Add a global forwarding rule

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]]

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

To get a list of 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]

In the API, make an empty GET request to the following URI:

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

Get forwarding rules

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

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

In 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

If you have already created a global forwarding rule but want to change the target proxy that the forwarding rule is using, 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]]

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]
}

Deleting global forwarding rules

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

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

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/forwardingRules/FORWARDING_RULE

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...

Compute Engine Documentation