WaveCDN API

Add a rule

Add a new rule to a given setup. The rule is only applied if the configured condition is true. You can add up to 50 rules per setup. Rules are evaluated in the order in which they were added. Certain rules may override previous rules.

Request

POST /rule

Request body

setup_id={..}

The id of the setup for which a rule should be added.

condition_type={..}

The type of the condition.

If the condition type always is specified, the rule is applied always. No further condition values need to be provided.

If the condition type ssl is specified, the rule is applied when it's an ssl request. No further condition values need to be provided.

If the condition types location, location_with_query_string or query_string are specified, you need to specify further parameters. The parameter condition_value1 must be one of the values begins_with, ends_with, contains and equals. The parameter condition_value2 should contain the string that is used for the match.

If the condition type cookie is specified, you need pass the additional parameters condition_value1 and condition_value2. The parameter condition_value1 must have the value exists or equals. The parameter condition_value2 must be the name of the cookie. If condition_value1 has the value equals a third additional parameter condition_value3 needs to be given, which is the value the cookie must have for the condition to be true.

rule_type={..}

The type of the rule.

If the rule type max_age is specified, a rule which adds a Cache-Control-Max-Age header will be added and WaveCDN will internally cache the requests for the given number of seconds. In this case the additional parameter rule_value1 needs to be given and specifies the number of seconds till expiration. Possible values are between 0 and 31536000 (one year).

If the rule type deny_access is specified, all requests that match the given condition will be denied and answered with the HTTP-response 403 Forbidden. This rule might override previous allow_access rules.

If the rule type allow_access is specified, all requests that match the given condition will be allowed. This rule might override previous deny_access rules.

Response

On success, the status code is 201 and the new rule is returned.

<?xml version="1.0" encoding="UTF-8"?>
<rule>
  <id>14549</id>
  <setup_id>9554</setup_id>
  <condition_type>location</condition_type>
  <condition_value1>contains</condition_value1>
  <condition_value2>result.json</condition_value2>
  <rule_type>pass_to_origin</rule_type>
</rule>