Load Balancer API

Manage load balancers programmatically using the RackCorp API

Overview

The Load Balancer API allows you to create, retrieve, update, and delete load balancers. Load balancers can be of type HTTP, CDN, or TCP, and support multiple backend servers with various balancing algorithms.

GET Get Load Balancer

Retrieve a single load balancer by its ID.

Request

{
  "cmd": "loadbalancer.get",
  "id": 123
}
<?php
$ch = curl_init('https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=loadbalancer.get&id=123');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer YOUR_JWT_TOKEN'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
?>
import requests

response = requests.get(
    'https://api.rackcorp.net/api/rest/v2.9/json.php',
    params={
        'cmd': 'loadbalancer.get',
        'id': 123
    },
    headers={
        'Authorization': 'Bearer YOUR_JWT_TOKEN'
    }
)

data = response.json()
curl -X GET "https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=loadbalancer.get&id=123" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
GET https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=loadbalancer.get&id=123
Authorization: Bearer YOUR_JWT_TOKEN

Parameters

Parameter Type Required Description
cmd string Yes Must be "loadbalancer.get"
id integer Yes Load balancer ID

Response

{
  "code": "OK",
  "loadbalancer": {
    "id": 123,
    "name": "My Load Balancer",
    "type": "HTTP",
    "hostname": "lb.example.com",
    "status": "ACTIVE",
    "customerid": 456,
    "backends": [
      {
        "name": "backend1",
        "hostname": "server1.example.com",
        "port": 80,
        "weight": 100,
        "timeout": 30,
        "tls": false,
        "tcpproxy": 0,
        "portmask": []
      }
    ],
    "balancemode": "roundrobin",
    "checkmode": "http",
    "checkurl": "/",
    "aliases": ["www.example.com", "example.com"],
    "regions": [5, 9],
    "refreshpatterns": [
      {
        "id": 456,
        "regularexpression": "\\.(gif|png|jpg)$",
        "maxttl": 3600,
        "minttl": 1800,
        "checkttl": 1800,
        "browserrefresh": "CACHE",
        "iprestrictiondefaultpolicy": "allow",
        "iprestrictions": [
          {
            "id": 789,
            "ip": "192.168.1.0/24",
            "action": "allow"
          }
        ]
      }
    ],
    "ports": [],
    "datecreated": 1699123456,
    "datemodified": 1699123456
  }
}

Note: The response includes all configured fields. For HTTP/CDN load balancers, aliases and refreshpatterns are included. For TCP load balancers, ports is included. Backends may include portmask for TCP load balancers. The regions array contains the region IDs where the load balancer is deployed.

Try This Request

GET List Load Balancers

Retrieve a list of load balancers with optional filtering and pagination.

Request

{
  "cmd": "loadbalancer.getall",
  "resStart": 0,
  "resWindow": 50,
  "keyword": "search term",
  "status": "ACTIVE"
}
<?php
$params = http_build_query([
    'cmd' => 'loadbalancer.getall',
    'resStart' => 0,
    'resWindow' => 50,
    'keyword' => 'search term',
    'status' => 'ACTIVE'
]);

$ch = curl_init('https://api.rackcorp.net/api/rest/v2.9/json.php?' . $params);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer YOUR_JWT_TOKEN'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
?>
import requests

response = requests.get(
    'https://api.rackcorp.net/api/rest/v2.9/json.php',
    params={
        'cmd': 'loadbalancer.getall',
        'resStart': 0,
        'resWindow': 50,
        'keyword': 'search term',
        'status': 'ACTIVE'
    },
    headers={
        'Authorization': 'Bearer YOUR_JWT_TOKEN'
    }
)

data = response.json()
curl -X GET "https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=loadbalancer.getall&resStart=0&resWindow=50&keyword=search%20term&status=ACTIVE" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
GET https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=loadbalancer.getall&resStart=0&resWindow=50&keyword=search%20term&status=ACTIVE
Authorization: Bearer YOUR_JWT_TOKEN

Parameters

Parameter Type Required Description
cmd string Yes Must be "loadbalancer.getall"
resStart integer No Pagination start offset (default: 0)
resWindow integer No Number of results per page (default: 20, minimum: 20)
keyword string No Search term to filter results
stdname string No Filter by standard name
status string No Filter by status (e.g., "ACTIVE")

Response

{
  "code": "OK",
  "count": 25,
  "loadbalancers": [
    {
      "id": 123,
      "name": "My Load Balancer",
      "type": "HTTP",
      "status": "ACTIVE",
      ...
    }
  ]
}

POST Create Load Balancer

Create a new load balancer with specified configuration.

Request

{
  "cmd": "loadbalancer.create",
  "type": "HTTP",
  "name": "My Load Balancer",
  "customerid": 456,
  "backends": [
    {
      "name": "backend1",
      "hostname": "server1.example.com",
      "port": 80,
      "weight": 100,
      "timeout": 30,
      "tls": false,
      "tcpproxy": 0
    }
  ],
  "balancemode": "roundrobin",
  "checkmode": "http",
  "checkurl": "/",
  "aliases": ["www.example.com", "example.com"],
  "regions": [5, 9],
  "refreshpatterns": [
    {
      "regularexpression": "\\.(gif|png|jpg)$",
      "maxttl": 3600,
      "minttl": 1800,
      "iprestrictiondefaultpolicy": "allow",
      "iprestrictions": [
        {
          "ip": "192.168.1.0/24",
          "action": "allow"
        }
      ]
    }
  ]
}
<?php
$ch = curl_init('https://api.rackcorp.net/api/rest/v2.9/json.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'cmd' => 'loadbalancer.create',
    'type' => 'HTTP',
    'name' => 'My Load Balancer',
    'customerid' => 456,
    'backends' => [
        [
            'name' => 'backend1',
            'hostname' => 'server1.example.com',
            'port' => 80,
            'weight' => 100,
            'timeout' => 30,
            'tls' => false,
            'tcpproxy' => 0
        ]
    ],
    'balancemode' => 'roundrobin',
    'checkmode' => 'http',
    'checkurl' => '/'
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer YOUR_JWT_TOKEN',
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
?>
import requests

response = requests.post(
    'https://api.rackcorp.net/api/rest/v2.9/json.php',
    json={
        'cmd': 'loadbalancer.create',
        'type': 'HTTP',
        'name': 'My Load Balancer',
        'customerid': 456,
        'backends': [
            {
                'name': 'backend1',
                'hostname': 'server1.example.com',
                'port': 80,
                'weight': 100,
                'timeout': 30,
                'tls': False,
                'tcpproxy': 0
            }
        ],
        'balancemode': 'roundrobin',
        'checkmode': 'http',
        'checkurl': '/'
    },
    headers={
        'Authorization': 'Bearer YOUR_JWT_TOKEN',
        'Content-Type': 'application/json'
    }
)

data = response.json()
curl -X POST "https://api.rackcorp.net/api/rest/v2.9/json.php" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "cmd": "loadbalancer.create",
    "type": "HTTP",
    "name": "My Load Balancer",
    "customerid": 456,
    "backends": [
      {
        "name": "backend1",
        "hostname": "server1.example.com",
        "port": 80,
        "weight": 100,
        "timeout": 30,
        "tls": false,
        "tcpproxy": 0
      }
    ],
    "balancemode": "roundrobin",
    "checkmode": "http",
    "checkurl": "/"
  }'

Parameters

Parameter Type Required Description
cmd string Yes Must be "loadbalancer.create"
type string Yes Load balancer type: "HTTP", "CDN", or "TCP"
name string Yes Load balancer name
customerid integer Yes Customer ID
backends array Yes Array of backend server objects
balancemode string Yes Balancing algorithm: "roundrobin", "least", or "random"
checkmode string Yes Health check mode: "http", "tcp", etc.
checkurl string No Health check URL (default: "/")
aliases array No Array of domain aliases (for HTTP/CDN types)
ports array No Array of port numbers (for TCP type only)
aliases array No Array of domain aliases (for HTTP/CDN types only)
regions array No Array of region IDs where the load balancer will be deployed. Use loadbalancer.region.getall to retrieve available regions. Best effort to give minimal latency is in effect.
refreshpatterns array No Array of refresh pattern objects for custom locations (for HTTP/CDN types). See Refresh Patterns section below.

Backend Object Structure

Field Type Required Description
name string Yes Backend server name
hostname string Yes Backend server hostname or IP
port integer Yes Backend server port (1-65535)
weight integer Yes Backend weight (1-1000)
timeout integer No Connection timeout in seconds (default: 30)
tls boolean No Enable TLS (for HTTP/CDN types)
tcpproxy integer No TCP Proxy version (0, 1, or 2). Use 2 for PROXY protocol v2.
portmask array No Array of port numbers this backend should handle (for TCP type only). Used with ports to map specific ports to specific backends.

Response

{
  "code": "OK",
  "message": "Successfully Created",
  "loadbalancer": {
    "id": 123,
    "name": "My Load Balancer",
    "type": "HTTP",
    "hostname": "lb.example.com",
    "status": "ACTIVE",
    "customerid": 456,
    "backends": [...],
    "balancemode": "roundrobin",
    "checkmode": "http",
    "checkurl": "/",
    "aliases": ["www.example.com", "example.com"],
    "refreshpatterns": [...],
    "datecreated": 1699123456,
    "datemodified": 1699123456
  }
}
Note: The response includes all configured fields including aliases and refresh patterns (if provided). Refresh patterns will include IP restrictions if they were configured.

PUT Update Load Balancer

Update an existing load balancer's configuration.

Request

{
  "cmd": "loadbalancer.update",
  "id": 123,
  "name": "Updated Load Balancer Name",
  "backends": [
    {
      "name": "backend1",
      "hostname": "server1.example.com",
      "port": 80,
      "weight": 100
    }
  ],
  "balancemode": "least"
}
<?php
$ch = curl_init('https://api.rackcorp.net/api/rest/v2.9/json.php');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'cmd' => 'loadbalancer.update',
    'id' => 123,
    'name' => 'Updated Load Balancer Name',
    'backends' => [
        [
            'name' => 'backend1',
            'hostname' => 'server1.example.com',
            'port' => 80,
            'weight' => 100
        ]
    ],
    'balancemode' => 'least'
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer YOUR_JWT_TOKEN',
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
?>
import requests

response = requests.put(
    'https://api.rackcorp.net/api/rest/v2.9/json.php',
    json={
        'cmd': 'loadbalancer.update',
        'id': 123,
        'name': 'Updated Load Balancer Name',
        'backends': [
            {
                'name': 'backend1',
                'hostname': 'server1.example.com',
                'port': 80,
                'weight': 100
            }
        ],
        'balancemode': 'least'
    },
    headers={
        'Authorization': 'Bearer YOUR_JWT_TOKEN',
        'Content-Type': 'application/json'
    }
)

data = response.json()
curl -X PUT "https://api.rackcorp.net/api/rest/v2.9/json.php" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "cmd": "loadbalancer.update",
    "id": 123,
    "name": "Updated Load Balancer Name",
    "backends": [
      {
        "name": "backend1",
        "hostname": "server1.example.com",
        "port": 80,
        "weight": 100
      }
    ],
    "balancemode": "least"
  }'

Parameters

All parameters from loadbalancer.create are supported, except type and customerid which cannot be changed. The id parameter is required.

You can update refresh patterns, IP restrictions, aliases, backends, regions, and all other configuration options. When updating refresh patterns, provide the complete array - it will replace all existing patterns. When updating regions, provide the complete array - it will replace all existing region assignments.

Response

{
  "code": "OK",
  "message": "Successfully Updated",
  "loadbalancer": {
    "id": 123,
    "name": "Updated Load Balancer Name",
    ...
  }
}

DELETE Delete Load Balancer

Delete a load balancer by its ID.

Request

{
  "cmd": "loadbalancer.delete",
  "id": 123
}
<?php
$ch = curl_init('https://api.rackcorp.net/api/rest/v2.9/json.php');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'cmd' => 'loadbalancer.delete',
    'id' => 123
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer YOUR_JWT_TOKEN',
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
?>
import requests

response = requests.delete(
    'https://api.rackcorp.net/api/rest/v2.9/json.php',
    json={
        'cmd': 'loadbalancer.delete',
        'id': 123
    },
    headers={
        'Authorization': 'Bearer YOUR_JWT_TOKEN',
        'Content-Type': 'application/json'
    }
)

data = response.json()
curl -X DELETE "https://api.rackcorp.net/api/rest/v2.9/json.php" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "cmd": "loadbalancer.delete",
    "id": 123
  }'

Parameters

Parameter Type Required Description
cmd string Yes Must be "loadbalancer.delete"
id integer Yes Load balancer ID to delete

Response

{
  "code": "OK",
  "message": "Load balancer deleted"
}

GET Get All Regions

Retrieve a list of all available deployment regions for load balancers.

Request

{
  "cmd": "loadbalancer.region.getall"
}
<?php
$ch = curl_init('https://api.rackcorp.net/api/rest/v2.9/json.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'cmd' => 'loadbalancer.region.getall'
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer YOUR_JWT_TOKEN',
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
?>
import requests

response = requests.post(
    'https://api.rackcorp.net/api/rest/v2.9/json.php',
    json={
        'cmd': 'loadbalancer.region.getall'
    },
    headers={
        'Authorization': 'Bearer YOUR_JWT_TOKEN',
        'Content-Type': 'application/json'
    }
)

data = response.json()
curl -X POST "https://api.rackcorp.net/api/rest/v2.9/json.php" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "cmd": "loadbalancer.region.getall"
  }'

Parameters

This endpoint does not require any parameters.

Response

{
  "code": "OK",
  "regions": [
    {
      "id": 5,
      "name": "Australia East",
      "code": "AU-EAST"
    },
    {
      "id": 9,
      "name": "United States West",
      "code": "US-WEST"
    }
  ]
}

Region Object Structure

Field Type Description
id integer Region ID (use this in the regions array when creating/updating load balancers)
name string Human-readable region name
code string Region code identifier

Usage Notes

Use this endpoint to retrieve the list of available regions before creating or updating a load balancer. The region IDs returned can be used in the regions parameter when creating or updating load balancers. Deployment regions determine where load balancers will be announced globally for your service. Best effort to give minimal latency is in effect.

Advanced Features

Load balancers support advanced configuration options depending on the type. HTTP and CDN load balancers support refresh patterns (custom locations) with IP restrictions, while TCP load balancers support port mapping. All load balancer types support deployment regions for global distribution with best-effort minimal latency.

Deployment Regions

Deployment regions allow you to specify where your load balancer will be announced globally. You can select one or more regions when creating or updating a load balancer. The system will make a best effort to provide minimal latency by routing traffic to the nearest available region.

To retrieve the list of available regions, use the loadbalancer.region.getall endpoint. Then include the region IDs in the regions array when creating or updating a load balancer.

{
  "cmd": "loadbalancer.create",
  "type": "HTTP",
  "name": "My Load Balancer",
  "customerid": 456,
  "regions": [5, 9],
  "backends": [...]
}

Note: If no regions are specified, the load balancer will be deployed to the default region. When updating regions, provide the complete array - it will replace all existing region assignments.

Refresh Patterns (Custom Locations)

Refresh patterns allow you to configure caching, redirects, and other behaviors for specific URL patterns in HTTP and CDN load balancers. Each pattern uses a regular expression to match URLs.

Refresh Pattern Object Structure

Field Type Required Description
regularexpression string Yes Regular expression pattern to match URLs (e.g., "\\.(gif|png|jpg)$")
maxttl integer No Maximum edge cache TTL in seconds (default: 0)
minttl integer No Minimum edge cache TTL in seconds (default: 0)
checkttl integer No Check TTL interval in seconds (default: 1800)
browserrefresh string No Browser refresh behavior: "CACHE", "REFRESH", or "NO_CACHE" (default: "CACHE")
redirectcode integer No HTTP redirect status code (300-399, e.g., 301, 302)
redirecturl string No Redirect destination URL (required if redirectcode is set)
forceexpiresmins integer No Force expiration time in minutes
overrideexpire boolean No Override Expires header from origin
overridelastmodified boolean No Override Last-Modified header from origin
ignoresetcookie boolean No Ignore Set-Cookie headers from origin
ignorecachecontrol boolean No Ignore Cache-Control headers from origin
cacheauthorizedpages boolean No Cache pages that require authorization
cgiignoreparams boolean No Ignore query parameters for CGI scripts
nocompression boolean No Disable compression for this pattern
pseudostreamflv boolean No Enable pseudo-streaming for FLV files
pseudostreamh264 boolean No Enable pseudo-streaming for H.264 files
iprestrictiondefaultpolicy string No Default IP restriction policy: "allow" or "deny" (default: "allow")
iprestrictions array No Array of IP restriction objects. See IP Restrictions below.

IP Restrictions

IP restrictions allow you to control access to specific refresh patterns based on client IP addresses. You can specify individual IPs or CIDR subnets, and set whether each should be allowed or denied.

IP Restriction Object Structure
Field Type Required Description
ip string Yes IP address or CIDR subnet (e.g., "192.168.1.1" or "192.168.1.0/24")
action string Yes Action to take: "allow" or "deny"
IP Restriction Example
{
  "cmd": "loadbalancer.create",
  "type": "HTTP",
  "name": "My Load Balancer",
  "customerid": 456,
  "backends": [...],
  "balancemode": "roundrobin",
  "checkmode": "http",
  "checkurl": "/",
  "refreshpatterns": [
    {
      "regularexpression": "\\.(gif|png|jpg)$",
      "maxttl": 3600,
      "minttl": 1800,
      "iprestrictiondefaultpolicy": "allow",
      "iprestrictions": [
        {
          "ip": "192.168.1.0/24",
          "action": "allow"
        },
        {
          "ip": "10.0.0.1",
          "action": "deny"
        }
      ]
    }
  ]
}
Note: The default policy applies when no specific IP restriction matches the client's IP address. If iprestrictiondefaultpolicy is "allow", all IPs are allowed unless explicitly denied. If it's "deny", all IPs are denied unless explicitly allowed.

TCP Port Mapping

For TCP load balancers, you can specify which ports the load balancer should listen on, and map specific ports to specific backend servers using the portmask field on backends.

Example: TCP Load Balancer with Port Mapping

{
  "cmd": "loadbalancer.create",
  "type": "TCP",
  "name": "My TCP Load Balancer",
  "customerid": 456,
  "ports": [80, 443, 8080],
  "backends": [
    {
      "name": "backend1",
      "hostname": "server1.example.com",
      "port": 80,
      "weight": 100,
      "portmask": [80, 8080]
    },
    {
      "name": "backend2",
      "hostname": "server2.example.com",
      "port": 443,
      "weight": 100,
      "portmask": [443]
    }
  ],
  "balancemode": "roundrobin",
  "checkmode": "tcp"
}

In this example, the load balancer listens on ports 80, 443, and 8080. Backend1 handles traffic on ports 80 and 8080, while backend2 handles traffic on port 443.

Domain Aliases (HTTP/CDN)

HTTP and CDN load balancers support domain aliases, allowing multiple domain names to point to the same load balancer.

Example: Load Balancer with Aliases

{
  "cmd": "loadbalancer.create",
  "type": "HTTP",
  "name": "My Load Balancer",
  "customerid": 456,
  "aliases": [
    "www.example.com",
    "example.com",
    "api.example.com"
  ],
  "backends": [...],
  "balancemode": "roundrobin",
  "checkmode": "http",
  "checkurl": "/"
}

Comprehensive Example

This example demonstrates creating an HTTP load balancer with all advanced features including multiple backends, aliases, refresh patterns, and IP restrictions.

Complete Create Request

{
  "cmd": "loadbalancer.create",
  "type": "HTTP",
  "name": "Production Web Load Balancer",
  "customerid": 456,
  "backends": [
    {
      "name": "web1",
      "hostname": "web1.example.com",
      "port": 80,
      "weight": 100,
      "timeout": 30,
      "tls": false,
      "tcpproxy": 0
    },
    {
      "name": "web2",
      "hostname": "web2.example.com",
      "port": 80,
      "weight": 100,
      "timeout": 30,
      "tls": false,
      "tcpproxy": 0
    },
    {
      "name": "web3",
      "hostname": "web3.example.com",
      "port": 80,
      "weight": 50,
      "timeout": 30,
      "tls": false,
      "tcpproxy": 0
    }
  ],
  "balancemode": "least",
  "checkmode": "http",
  "checkurl": "/health",
  "aliases": [
    "www.example.com",
    "example.com",
    "api.example.com"
  ],
  "refreshpatterns": [
    {
      "regularexpression": "\\.(gif|png|jpg|jpeg|webp)$",
      "maxttl": 86400,
      "minttl": 3600,
      "checkttl": 1800,
      "browserrefresh": "CACHE",
      "overrideexpire": true,
      "overridelastmodified": true,
      "ignoresetcookie": true,
      "ignorecachecontrol": false,
      "cacheauthorizedpages": false,
      "cgiignoreparams": false,
      "nocompression": false,
      "iprestrictiondefaultpolicy": "allow",
      "iprestrictions": [
        {
          "ip": "192.168.1.0/24",
          "action": "allow"
        },
        {
          "ip": "10.0.0.0/8",
          "action": "allow"
        }
      ]
    },
    {
      "regularexpression": "^/api/",
      "maxttl": 0,
      "minttl": 0,
      "checkttl": 1800,
      "browserrefresh": "NO_CACHE",
      "ignorecachecontrol": false,
      "cacheauthorizedpages": true,
      "iprestrictiondefaultpolicy": "deny",
      "iprestrictions": [
        {
          "ip": "203.0.113.0/24",
          "action": "allow"
        },
        {
          "ip": "198.51.100.50",
          "action": "allow"
        }
      ]
    },
    {
      "regularexpression": "\\.(mp4|flv)$",
      "maxttl": 3600,
      "minttl": 1800,
      "pseudostreamflv": true,
      "pseudostreamh264": true,
      "iprestrictiondefaultpolicy": "allow"
    },
    {
      "regularexpression": "^/old-site/",
      "redirectcode": 301,
      "redirecturl": "/new-site/",
      "iprestrictiondefaultpolicy": "allow"
    }
  ]
}

Example Explanation

  • Backends: Three backend servers with different weights (web3 has 50% weight)
  • Balance Mode: "least" connections for better distribution
  • Health Check: HTTP check on /health endpoint
  • Aliases: Three domain names pointing to this load balancer
  • Refresh Pattern 1: Images cache for 24 hours with IP restrictions allowing internal networks
  • Refresh Pattern 2: API endpoints with no caching and strict IP restrictions (deny by default, allow specific IPs)
  • Refresh Pattern 3: Video files with pseudo-streaming enabled
  • Refresh Pattern 4: URL redirect from old to new location

Error Responses

If an error occurs, the API will return a response with code: "FAULT":

{
  "code": "FAULT",
  "message": "Error message",
  "error": {
    "field1": "Error message 1",
    "field2": "Error message 2"
  }
}

Common error scenarios:

  • Invalid load balancer ID
  • Missing required parameters
  • Invalid backend configuration
  • Permission denied