This is a Limited Preview release of HTTP load balancing. As a result, it might be changed in backward-incompatible ways and is not recommended for production use. It is not subject to any SLA or deprecation policy. Request to be whitelisted to use this feature .
Global forwarding rules route traffic by IP address, port, and protocol to a
load balancing configuration consisting of a target proxy, and URL map. The
backend services are drawn from available instances that are grouped into
resource views objects. The global forwarding rule provides a single global IP
address that you can use in the DNS records for your application.
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.
Adding 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 | PORT-PORT]]
[--target-http-proxy TARGET_HTTP_PROXY | --target-instance TARGET_INSTANCE | --target-pool TARGET_POOL]
[--target-instance-zone TARGET_INSTANCE_ZONE]
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_INSTANCE | TARGET_POOL
}
Listing 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
Getting forwarding rules
To get a information about a single forwarding rule with
gcloud compute
, use
the
forwarding-rules get
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>
Updating the global forwarding rule target
If you have already created a global forwarding rule but want to change the
target HTTP proxy that the forwarding rule is using using
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]
In the API, send a POST request to the URI below, passing the name of the target HTTP proxy resource 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": TARGET_HTTP_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>