CDNs and Hosts

Configuring CDNs and hosts
You're viewing a development version of router, the latest released version is 1.24.0

The current page CDNs and Hosts doesn't exist in version 1.24.0 of the documentation for this product.
We can take you to the closest parent section instead: /docs/acd/components/router/1.24.0/configuration/

In order to route requests, the ESB3024 CDN Director needs to be configured with hosts that can serve them. Hosts are grouped in host groups, where each group contains hosts that share some common settings. There are three types of host groups: host, redirecting and DNS:

  • host: Content is served directly. An example of a such a host is the ESB3004 SW Streamer.
  • redirecting: These hosts are themselves CDN selectors. The CDN Director expects a redirecting CDN to respond with a redirection URL which tells where the content can be found. A typical redirecting CDN is the ESB3008 Convoy Request Router.
  • DNS: These hosts are EDNS servers. The CDN Director sends DNS requests to these hosts and expects them to respond with an IP address where the content can be found.

Each host group contains a list of hosts. In addition to that, the host groups have different parameters depending on their type.

Each type also has a templated variant, hostTemplate, redirectingTemplate and dnsTemplate, where the hosts are generated from a single host template instead of being listed one by one. See Templated host groups.

Host group names as routing targets

Routing rules and the routing entrypoint can target a host group by its name. When a host group name is used as a target, the CDN Director automatically distributes traffic across the hosts in that group. By default, requests are distributed randomly and uniformly. This can be overridden with the loadBalancer parameter (see Parameters shared by host and redirecting host groups).

Thus, instead of manually creating a random or consistentHashing rule block that lists each host individually, you can simply point a routing rule (or the entrypoint) at the host group name and let the CDN Director handle the load balancing.

Common host group parameters

These parameters are present in all host groups:

  • name: The name of the host group. This is used to reference the host group from other parts of the configuration. The name can also be used directly as a routing target in rules and as the routing entrypoint (see Host group names as routing targets).
  • type: The type of the host group as listed above.
  • headersToForward: A list of HTTP headers to forward from the client to the CDN. This is useful if the CDN needs to know about the original Host header or any custom headers added by the client or an upstream proxy. If the incoming request contains an X-Forwarded-For header, that header will be forwarded to the CDN even if it is not listed.
  • queryPassThrough: Controls which query parameters from the client request are forwarded to the backend and included in the redirection URL. It has two fields:
    • policy: accept (default) or deny. accept forwards all query parameters except those listed in exceptions. deny blocks all query parameters except those listed in exceptions.
    • exceptions: A list of query parameter names to exclude from the policy.

Host specification

Along with these parameters, a host group also contains a host specification, which is different depending on the type of the host group:

  • Regular host groups have hosts, which is a list of hosts in this host group. The configuration of hosts is detailed in Hosts below.
  • Templated host groups have hostTemplate and instances instead, see Templated host groups.

Parameters shared by host and redirecting host groups

These parameters are only present in host and redirecting host groups:

  • httpPort: The port to use when sending HTTP requests to the hosts in this group.

  • httpsPort: The port to use when sending HTTPS requests to the hosts in this group.

  • loadBalancer: An optional object that overrides the default random load balancing strategy used when the host group name is targeted by a routing rule or the entrypoint. It has the following fields:

    • type (required): The load balancing algorithm to use. Must be "random" or "consistentHashing".
    • spreadFactor: The number of preferred hosts to distribute requests across when using consistentHashing. Integer between 1 and 64 (default: 1). Only meaningful when type is "consistentHashing".
    • hashAlgorithm: The hashing algorithm to use for consistentHashing. "MD5" (default), "SDBM" or "Murmur". Only meaningful when type is "consistentHashing".

    When loadBalancer is not set, the host group uses random load balancing by default. See Consistent Hashing for more details on the consistent hashing algorithm.

host group parameters

These parameters are only present in host host groups:

  • createStreamerSession: AgileTV streamers require a session to be allocated when redirecting to them. Setting this parameter to true tells the CDN Director to create such a session when redirecting to hosts in this group.
  • addUrlPrefix: Enables adding a URL prefix to requests that are redirected to hosts in this group. See URL Prefixes for more information.

redirecting group parameters

These parameters are only present in redirecting host groups:

  • allowAnyRedirectType: The CDN Director expects redirecting CDNs to redirect with response code 302. Setting this parameter to true allows the CDN Director to accept any 3xx response code as a redirection URL.

Hosts

The hosts parameter is the same in all host groups. It contains a list of hosts, each with the following parameters:

  • name: The name of the host. This is used to reference the host from other parts of the configuration.
  • hostname: The hostname of the host. This is where requests are sent. It can be an IPv4 address or a domain name.
  • ipv6_address: The IPv6 address of the host. This is used when the CDN Director needs to send requests to the host over IPv6. If this parameter is not set, the CDN Director will use the hostname parameter for both IPv4 and IPv6 requests.
  • healthChecks: A list of Lua functions to determine if the host is healthy and can be selected for routing. If any of the health check functions returns false, the host will be considered unhealthy and will not be selected for routing. All health check functions are detailed in the section Built-in Lua functions.

Templated host groups

Large deployments often have host groups where every host follows the same pattern, e.g. one host per PoP, and the hosts only differ by an identifier or a few other values. Instead of listing every host by hand, such a group can be configured as a templated host group, where the host is described once and the values that differ are given per host.

There is one templated host group type for each regular host group type:

Templated typeRegular type
hostTemplatehost
redirectingTemplateredirecting
dnsTemplatedns

A templated host group has the same parameters as the corresponding regular host group, including loadBalancer, except that hosts is replaced by:

  • hostTemplate: A single host with the same parameters as described in Hosts. Any string value, including the health checks, may contain placeholders on the form {{name}}. Whitespace inside the braces is allowed, so {{ name }} is the same placeholder.
  • instances: A list with one entry per host to generate. Each instance has a parameters list of name and value pairs, where name is the name of a placeholder, without the braces, and value is the string that replaces it.

One host is generated per instance, in the order the instances are listed, by replacing every placeholder in hostTemplate with the value from the instance. The templated host group is expanded into a regular host group before the configuration reaches the CDN Director, so it can be used exactly like a regular host group, e.g. as a routing target. Since the generated hosts are regular hosts, their names must be unique and can be targeted by routing rules like any other host, so the name of the template usually needs to contain a placeholder.

The parameter names enabled and weight are reserved and can’t be used as placeholders. Instead, they control how the instance’s host is load balanced:

  • weight: Gives the instance’s host a weight, so that hosts can get different shares of the traffic, e.g. because they have different capacity. If any instance in a host group with a random load balancer sets weight, the group is load balanced like a weighted rule instead, see Routing Rules. The value can be anything that is valid as a weight in a weighted rule, i.e. a non-negative integer or a function call such as si('sto1.capacity'), so the shares can change at runtime. With a consistentHashing load balancer, which distributes requests based on their content, the weight parameter is ignored and confcli warns about it.
  • enabled: Enables or disables the instance’s host in a consistentHashing load balancer, see Consistent Hashing, or in a load balancer using weights. A disabled host is kept in the host group, but no requests are distributed to it. The value is true or false, regardless of case, and defaults to true. With a random load balancer without weights, the enabled parameter is ignored and confcli warns about it.

To make it possible to build up or empty a templated host group step by step, the following are only reported as warnings by confcli, and do not prevent the configuration from being stored:

  • An instance that lacks a value for one of the placeholders. No host is generated for such an instance.
  • An instance without a weight, when other instances in the group have one. No host is generated for such an instance, so that weights can be added one instance at a time without sending traffic to hosts whose weight hasn’t been decided yet. Set weight on all instances or none of them.
  • An empty instances list. No hosts are generated for the group. Note that a group without hosts can’t be used as a routing target.
  • A parameter that isn’t used by any placeholder in hostTemplate, e.g. because of a misspelled name.

The following example generates three hosts, streamer-sto, streamer-gbg and streamer-mmo, and distributes requests between them using consistent hashing. The host streamer-mmo is disabled in the load balancer, without having to be removed from the host group:

{
  "hostGroups": [
    {
      "name": "streamers",
      "type": "hostTemplate",
      "httpPort": 80,
      "httpsPort": 443,
      "loadBalancer": {
        "type": "consistentHashing",
        "spreadFactor": 2,
        "hashAlgorithm": "MD5"
      },
      "hostTemplate": {
        "name": "streamer-{{pop}}",
        "hostname": "streamer.{{pop}}.example.com",
        "healthChecks": [
          "health_check({interfaces = '{{interface}}'})"
        ]
      },
      "instances": [
        {
          "parameters": [
            {"name": "pop", "value": "sto"},
            {"name": "interface", "value": "eths0"}
          ]
        },
        {
          "parameters": [
            {"name": "pop", "value": "gbg"},
            {"name": "interface", "value": "eths0"}
          ]
        },
        {
          "parameters": [
            {"name": "pop", "value": "mmo"},
            {"name": "interface", "value": "eths1"},
            {"name": "enabled", "value": "false"}
          ]
        }
      ]
    }
  ],
  "entrypoint": "streamers"
}

After expansion, the streamers host group is a regular host group, where the first host is:

{
  "name": "streamer-sto",
  "hostname": "streamer.sto.example.com",
  "healthChecks": [
    "health_check({interfaces = 'eths0'})"
  ]
}

The following example instead distributes requests between the hosts by weight. streamer-sto gets twice the share of streamer-gbg, while the weight of streamer-mmo is read at runtime from the selection input:

{
  "hostGroups": [
    {
      "name": "streamers",
      "type": "hostTemplate",
      "httpPort": 80,
      "httpsPort": 443,
      "loadBalancer": {
        "type": "random"
      },
      "hostTemplate": {
        "name": "streamer-{{pop}}",
        "hostname": "streamer.{{pop}}.example.com"
      },
      "instances": [
        {
          "parameters": [
            {"name": "pop", "value": "sto"},
            {"name": "weight", "value": "200"}
          ]
        },
        {
          "parameters": [
            {"name": "pop", "value": "gbg"},
            {"name": "weight", "value": "100"}
          ]
        },
        {
          "parameters": [
            {"name": "pop", "value": "mmo"},
            {"name": "weight", "value": "si('mmo.capacity')"}
          ]
        }
      ]
    }
  ],
  "entrypoint": "streamers"
}

Configuration examples

Below are some examples on how different types of host groups with hosts can be configured.

$ confcli services.routing.hostGroups -w
Running wizard for resource 'hostGroups'

Hint: Hitting return will set a value to its default.
Enter '?' to receive the help string

hostGroups : [
  hostGroup can be one of
    1: dns
    2: dnsTemplate
    3: host
    4: hostTemplate
    5: redirecting
    6: redirectingTemplate
  Choose element index or name: host
  Adding a 'host' element
    hostGroup : {
      name (default: ): streamers
      type (default: host): ⏎
      httpPort (default: 80): ⏎
      httpsPort (default: 443): ⏎
      headersToForward <A list of HTTP headers to forward to the CDN. (default: [])>: [
        headersToForward (default: ): ⏎
        Add another 'headersToForward' element to array 'headersToForward'? [y/N]: ⏎
      ]
      queryPassThrough <Controls which query parameters from the client request are forwarded to the backend and included in the redirection URL. (default: OrderedDict())>: {
        policy (default: accept): ⏎
        exceptions <Query parameters excluded from the policy. When policy is 'accept', these are blocked. When policy is 'deny', these are forwarded. (default: [])>: [
          exceptions (default: ): ⏎
          Add another 'exceptions' element to array 'exceptions'? [y/N]: ⏎
        ]
      }
      createStreamerSession (default: False): True
      addUrlPrefix (default: False): ⏎
      loadBalancer <Overrides the default random strategy. (default: OrderedDict())>: {
        type (default: random): ⏎
        spreadFactor (default: 1): ⏎
        hashAlgorithm (default: MD5): ⏎
      }
      hosts : [
        host : {
          name (default: ): streamer1
          hostname (default: ): streamer1.example.com
          ipv6_address (default: ): ⏎
          healthChecks : [
            healthCheck (default: always()): health_check()
            Add another 'healthCheck' element to array 'healthChecks'? [y/N]: n
          ]
        }
        Add another 'host' element to array 'hosts'? [y/N]: y
        host : {
          name (default: ): streamer2
          hostname (default: ): streamer2.example.com
          ipv6_address (default: ): ⏎
          healthChecks : [
            healthCheck (default: always()): ⏎
            Add another 'healthCheck' element to array 'healthChecks'? [y/N]: n
          ]
        }
        Add another 'host' element to array 'hosts'? [y/N]: ⏎
      ]
    }
  Add another 'hostGroup' element to array 'hostGroups'? [y/N]: ⏎
]
Generated config:
{
  "hostGroups": [
    {
      "name": "streamers",
      "type": "host",
      "httpPort": 80,
      "httpsPort": 443,
      "headersToForward": [
        ""
      ],
      "queryPassThrough": {
        "policy": "accept",
        "exceptions": [
          ""
        ]
      },
      "createStreamerSession": true,
      "addUrlPrefix": false,
      "loadBalancer": {
        "type": "random",
        "spreadFactor": 1,
        "hashAlgorithm": "MD5"
      },
      "hosts": [
        {
          "name": "streamer1",
          "hostname": "streamer1.example.com",
          "ipv6_address": "",
          "healthChecks": [
            "health_check()"
          ]
        },
        {
          "name": "streamer2",
          "hostname": "streamer2.example.com",
          "ipv6_address": "",
          "healthChecks": [
            "always()"
          ]
        }
      ]
    }
  ]
}
Merge and apply the config? [y/n]: y
  
$ confcli services.routing.hostGroups -w
Running wizard for resource 'hostGroups'

Hint: Hitting return will set a value to its default.
Enter '?' to receive the help string

hostGroups : [
  hostGroup can be one of
    1: dns
    2: dnsTemplate
    3: host
    4: hostTemplate
    5: redirecting
    6: redirectingTemplate
  Choose element index or name: redirecting
  Adding a 'redirecting' element
    hostGroup : {
      name (default: ): edgeware
      type (default: redirecting): ⏎
      httpPort (default: 80): ⏎
      httpsPort (default: 443): ⏎
      headersToForward <A list of HTTP headers to forward to the CDN. (default: [])>: [
        headersToForward (default: ): ⏎
        Add another 'headersToForward' element to array 'headersToForward'? [y/N]: ⏎
      ]
      queryPassThrough <Controls which query parameters from the client request are forwarded to the backend and included in the redirection URL. (default: OrderedDict())>: {
        policy (default: accept): ⏎
        exceptions <Query parameters excluded from the policy. When policy is 'accept', these are blocked. When policy is 'deny', these are forwarded. (default: [])>: [
          exceptions (default: ): ⏎
          Add another 'exceptions' element to array 'exceptions'? [y/N]: ⏎
        ]
      }
      allowAnyRedirectType (default: False): ⏎
      loadBalancer <Overrides the default random strategy. (default: OrderedDict())>: {
        type (default: random): ⏎
        spreadFactor (default: 1): ⏎
        hashAlgorithm (default: MD5): ⏎
      }
      hosts : [
        host : {
          name (default: ): rr1
          hostname (default: ): convoy-rr1.example.com
          ipv6_address (default: ): ⏎
          healthChecks : [
            healthCheck (default: always()): health_check()
            Add another 'healthCheck' element to array 'healthChecks'? [y/N]: n
          ]
        }
        Add another 'host' element to array 'hosts'? [y/N]: y
        host : {
          name (default: ): rr2
          hostname (default: ): convoy-rr2.example.com
          ipv6_address (default: ): ⏎
          healthChecks : [
            healthCheck (default: always()): ⏎
            Add another 'healthCheck' element to array 'healthChecks'? [y/N]: n
          ]
        }
        Add another 'host' element to array 'hosts'? [y/N]: ⏎
      ]
    }
  Add another 'hostGroup' element to array 'hostGroups'? [y/N]: ⏎
]
Generated config:
{
  "hostGroups": [
    {
      "name": "edgeware",
      "type": "redirecting",
      "httpPort": 80,
      "httpsPort": 443,
      "headersToForward": [
        ""
      ],
      "queryPassThrough": {
        "policy": "accept",
        "exceptions": [
          ""
        ]
      },
      "allowAnyRedirectType": false,
      "loadBalancer": {
        "type": "random",
        "spreadFactor": 1,
        "hashAlgorithm": "MD5"
      },
      "hosts": [
        {
          "name": "rr1",
          "hostname": "convoy-rr1.example.com",
          "ipv6_address": "",
          "healthChecks": [
            "health_check()"
          ]
        },
        {
          "name": "rr2",
          "hostname": "convoy-rr2.example.com",
          "ipv6_address": "",
          "healthChecks": [
            "always()"
          ]
        }
      ]
    }
  ]
}
Merge and apply the config? [y/n]: y
  
$ confcli services.routing.hostGroups -w
Running wizard for resource 'hostGroups'

Hint: Hitting return will set a value to its default.
Enter '?' to receive the help string

hostGroups : [
  hostGroup can be one of
    1: dns
    2: dnsTemplate
    3: host
    4: hostTemplate
    5: redirecting
    6: redirectingTemplate
  Choose element index or name: host
  Adding a 'host' element
    hostGroup : {
      name (default: ): streamers
      type (default: host): ⏎
      httpPort (default: 80): ⏎
      httpsPort (default: 443): ⏎
      headersToForward <A list of HTTP headers to forward to the CDN. (default: [])>: [
        headersToForward (default: ): ⏎
        Add another 'headersToForward' element to array 'headersToForward'? [y/N]: ⏎
      ]
      queryPassThrough <Controls which query parameters from the client request are forwarded to the backend and included in the redirection URL. (default: OrderedDict())>: {
        policy (default: accept): ⏎
        exceptions <Query parameters excluded from the policy. When policy is 'accept', these are blocked. When policy is 'deny', these are forwarded. (default: [])>: [
          exceptions (default: ): ⏎
          Add another 'exceptions' element to array 'exceptions'? [y/N]: ⏎
        ]
      }
      createStreamerSession (default: False): ⏎
      addUrlPrefix (default: False): ⏎
      loadBalancer <Overrides the default random strategy. (default: OrderedDict())>: {
        type (default: random): consistentHashing
        spreadFactor (default: 1): 2
        hashAlgorithm (default: MD5): ⏎
      }
      hosts : [
        host : {
          name (default: ): streamer1
          hostname (default: ): streamer1.example.com
          ipv6_address (default: ): ⏎
          healthChecks : [
            healthCheck (default: always()): health_check()
            Add another 'healthCheck' element to array 'healthChecks'? [y/N]: n
          ]
        }
        Add another 'host' element to array 'hosts'? [y/N]: y
        host : {
          name (default: ): streamer2
          hostname (default: ): streamer2.example.com
          ipv6_address (default: ): ⏎
          healthChecks : [
            healthCheck (default: always()): ⏎
            Add another 'healthCheck' element to array 'healthChecks'? [y/N]: n
          ]
        }
        Add another 'host' element to array 'hosts'? [y/N]: ⏎
      ]
    }
  Add another 'hostGroup' element to array 'hostGroups'? [y/N]: ⏎
]
Generated config:
{
  "hostGroups": [
    {
      "name": "streamers",
      "type": "host",
      "httpPort": 80,
      "httpsPort": 443,
      "headersToForward": [
        ""
      ],
      "queryPassThrough": {
        "policy": "accept",
        "exceptions": [
          ""
        ]
      },
      "createStreamerSession": false,
      "addUrlPrefix": false,
      "loadBalancer": {
        "type": "consistentHashing",
        "spreadFactor": 2,
        "hashAlgorithm": "MD5"
      },
      "hosts": [
        {
          "name": "streamer1",
          "hostname": "streamer1.example.com",
          "ipv6_address": "",
          "healthChecks": [
            "health_check()"
          ]
        },
        {
          "name": "streamer2",
          "hostname": "streamer2.example.com",
          "ipv6_address": "",
          "healthChecks": [
            "always()"
          ]
        }
      ]
    }
  ]
}
Merge and apply the config? [y/n]: y
  
$ confcli services.routing.hostGroups -w
Running wizard for resource 'hostGroups'

Hint: Hitting return will set a value to its default.
Enter '?' to receive the help string

hostGroups : [
  hostGroup can be one of
    1: dns
    2: dnsTemplate
    3: host
    4: hostTemplate
    5: redirecting
    6: redirectingTemplate
  Choose element index or name: dns
  Adding a 'dns' element
    hostGroup : {
      name (default: ): external-dns
      type (default: dns): ⏎
      headersToForward <A list of HTTP headers to forward to the CDN. (default: [])>: [
        headersToForward (default: ): ⏎
        Add another 'headersToForward' element to array 'headersToForward'? [y/N]: n
      ]
      queryPassThrough <Controls which query parameters from the client request are forwarded to the backend and included in the redirection URL. (default: OrderedDict())>: {
        policy (default: accept): ⏎
        exceptions <Query parameters excluded from the policy. When policy is 'accept', these are blocked. When policy is 'deny', these are forwarded. (default: [])>: [
          exceptions (default: ): ⏎
          Add another 'exceptions' element to array 'exceptions'? [y/N]: ⏎
        ]
      }
      loadBalancer <Overrides the default random strategy. (default: OrderedDict())>: {
        type (default: random): ⏎
        spreadFactor (default: 1): ⏎
        hashAlgorithm (default: MD5): ⏎
      }
      hosts : [
        host : {
          name (default: ): dns-host
          hostname (default: ): dns.example.com
          ipv6_address (default: ): ⏎
          healthChecks : [
            healthCheck (default: always()): ⏎
            Add another 'healthCheck' element to array 'healthChecks'? [y/N]: n
          ]
        }
        Add another 'host' element to array 'hosts'? [y/N]: ⏎
      ]
    }
  Add another 'hostGroup' element to array 'hostGroups'? [y/N]: ⏎
]
Generated config:
{
  "hostGroups": [
    {
      "name": "external-dns",
      "type": "dns",
      "headersToForward": [
        ""
      ],
      "queryPassThrough": {
        "policy": "accept",
        "exceptions": [
          ""
        ]
      },
      "loadBalancer": {
        "type": "random",
        "spreadFactor": 1,
        "hashAlgorithm": "MD5"
      },
      "hosts": [
        {
          "name": "dns-host",
          "hostname": "dns.example.com",
          "ipv6_address": "",
          "healthChecks": [
            "always()"
          ]
        }
      ]
    }
  ]
}
Merge and apply the config? [y/n]: y