Skip to content
  • Auto
  • Light
  • Dark

Add

Add Forwarding Rules to a Load Balancer
post/v2/load_balancers/{lb_id}/forwarding_rules

To add an additional forwarding rule to a load balancer instance, send a POST request to /v2/load_balancers/$LOAD_BALANCER_ID/forwarding_rules. In the body of the request, there should be a forwarding_rules attribute containing an array of rules to be added.

No response body will be sent back, but the response code will indicate success. Specifically, the response code will be a 204, which means that the action was successful with no returned body data.

Path ParametersExpand Collapse
lb_id: string
minimum1
Body ParametersExpand Collapse
forwarding_rules: array of ForwardingRule { entry_port, entry_protocol, target_port, 3 more }
entry_port: number

An integer representing the port on which the load balancer instance will listen.

entry_protocol: "http" or "https" or "http2" or 3 more

The protocol used for traffic to the load balancer. The possible values are: http, https, http2, http3, tcp, or udp. If you set the entry_protocol to udp, the target_protocol must be set to udp. When using UDP, the load balancer requires that you set up a health check with a port that uses TCP, HTTP, or HTTPS to work properly.

Accepts one of the following:
"http"
"https"
"http2"
"http3"
"tcp"
"udp"
target_port: number

An integer representing the port on the backend Droplets to which the load balancer will send traffic.

target_protocol: "http" or "https" or "http2" or 2 more

The protocol used for traffic from the load balancer to the backend Droplets. The possible values are: http, https, http2, tcp, or udp. If you set the target_protocol to udp, the entry_protocol must be set to udp. When using UDP, the load balancer requires that you set up a health check with a port that uses TCP, HTTP, or HTTPS to work properly.

Accepts one of the following:
"http"
"https"
"http2"
"tcp"
"udp"
certificate_id: optional string

The ID of the TLS certificate used for SSL termination if enabled.

tls_passthrough: optional boolean

A boolean value indicating whether SSL encrypted traffic will be passed through to the backend Droplets.

Add Forwarding Rules to a Load Balancer
curl https://api.digitalocean.com/v2/load_balancers/$LB_ID/forwarding_rules \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $DIGITALOCEAN_ACCESS_TOKEN" \
    -d '{
          "forwarding_rules": [
            {
              "entry_port": 443,
              "entry_protocol": "https",
              "target_port": 80,
              "target_protocol": "http"
            }
          ]
        }'
Returns Examples