Global forwarding rules

The global forwarding rule provides a single global IP address that you can use in DNS records for your site. Global forwarding rules route traffic by IP address, port, and protocol to a load balancing configuration consisting of a target proxy and URL map, which in turn forward the traffic to an instance group containing your virtual machine instances.

Global forwarding rules can only be used with an HTTP/HTTPS load balancer configuration. A single global forwarding rule can only forward to a single port.

Contents

Global forwarding rule properties

See the GlobalForwardingRule resource for descriptions of the properties available when working with global forwarding rules through either the REST API or the gcloud command-line tool.

Add a global forwarding rule

To add a new global forwarding rule with gcloud compute, use the forwarding-rules create subcommand:

gcloud compute forwarding-rules create
    FORWARDING_RULE --global
    [--address ADDRESS]
    [--description DESCRIPTION]
    [--ip-protocol IP_PROTOCOL]
    [--port-range PORT]
    [--target-http-proxy TARGET_HTTP_PROXY | --target-https-proxy TARGET_HTTPS_PROXY ]

To add a 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": NAME,
  "IPAddress": EXTERNAL_IP,
  "IPProtocol": TCP_OR_UDP,
  "portRange": PORT_RANGE,
  "target": TARGET_HTTP_PROXY | TARGET_HTTPS_PROXY
}

List global forwarding rules

To get a list of forwarding rules with gcloud compute, 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 with gcloud compute, 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 HTTP or HTTPS proxy that the forwarding rule is using with gcloud compute, use the forwarding-rules set-target sub-command:

gcloud compute forwarding-rules set-target FORWARDING_RULE --global
    [--target-http-proxy TARGET_HTTP_PROXY | --target-https-proxy TARGET_HTTPS_PROXY]

In the API, send a POST request to the URI below, passing the name of the target HTTP proxy resource or target HTTPS proxy resource that you want to set in the request body:

HTTP

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

{
  "target": TARGET_HTTP_PROXY
}

HTTPS

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

{
  "target": TARGET_HTTPS_PROXY
}

Deleting global forwarding rules

To delete a forwarding rule with gcloud compute, 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

Send feedback about...

Compute Engine Documentation