# Application HTTP Rewrite Rule

# Get the HTTP application rewrite rule

# Description

Get the rewrite rule of the http application.

# Uri
GET /admin-api/applications/phases/rewrite/rules
# Json body
  • enable_rule

    type: boolean

    description: whether to enable the rule.

  • locked_rule

    type: boolean

    description: whether lock this rule for users from edge admin (cannot be edited and deleted)

  • top

    type: integer

    description: the order of the current rule in the rule chain, default is 0. The larger the value, the higher the ranking.

  • order

    type: integer

    description: the order of the current rule in the rule chain, default is 0. The smaller the value, the higher the ranking.

  • last

    type: boolean

    description: when the value is 'true', the rule will be at the last of rule chains.

  • comment

    type: string

    description: the comment info for the rule.

  • conditions

    type: array

    description: the prerequisites for the rule.

  • conditions[*].variable

    type: object

    description: TODO

  • conditions[*].caseless

    type: boolean

    description: ignore case when comparing string

  • conditions[*].operator

    type: enum

    description: operator for comparing between conditions and values. legal operators: ==, '!=', <, <=, '>', '>=', eq, ne, lt, le, gt, ge, '', '!', contains, contains-word, prefix, suffix, '!contains', '!contains-word', '!prefix', '!suffix', 'is-empty', '!is-empty'

  • conditions[*].values

    type: array

    description: values for comparing with conditions

  • conditions[].values[].type

    type: enum

    description: type for value. legal types: str, rx, wc, netaddr, uv, global-uv.

  • conditions[*].ip_list

    type: array

    description: reference global ip list by id.

  • conditions[].ip_list[]

    type: int

    description: id of global_ip_list.

  • actions

    type: array

    description: actions to be performed in the rules.

  • actions[*]

    type: object

    description: TODO

  • waf

    type: object

    description: the waf rule.

  • content

    type: object

    description: content of the response, now supports setting the favicon and empty_gif.

  • content.favicon

    type: integer

    description: the id of the favicon uploaded in the global config.

  • content.empty_gif

    type: boolean

    description: when the value is 'true', will response a empty_gif.

  • proxy

    type: object

    description: the proxy rule.

  • cache

    type: object

    description: the cache setting of the rule.

  • cache.enforce_cache

    type: boolean

    description: whether to enforce the server to cache the content, ignoring the cache headers from the origin site.

  • cache.default_ttls

    type: array

    description: default cache ttls for origin site that have no cache rules according to the upstream response code.

  • cache.default_ttls[*]

    type: object

  • cache.default_ttls[*].ttl

    type: integer

    description: Time-To-Live of the cache rule.

  • cache.default_ttls[*].ttl_unit

    type: enum

    description: the unit of the ttl, can be one of 's' / 'min' / 'hour' / 'day'

  • cache.cluster_hash

    type: boolean

    description: whether enable the cluster hash

  • cache.disable_convert_head

    type: boolean

    description: we convert the HEAD request into a GET request to check the cache, when disable_convert_head is true, the convertion does not happen.

  • cache.cache_key

    type: object

    description: the cache key of the resources.

  • cache.enable_global

    type: boolean

    description: whether the current resource is shared cache in the global application scope, by default the resource is shared cache in the scope of the current application.

  • cache.browser_ttl

    type: integer

    description: modify the standard cache ttl for browser.

  • cache.browser_ttl_unit

    type: enum

    description: the unit of the browser_ttl_unit, can be one of 's' / 'min' / 'hour' / 'day'.

  • user_code

    type: string

    required: no

    description: user defined edgelang code for the application.

# Example Request
curl \
  -H "API-token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  http://{admin-site}/admin-api/applications/http/1/phases/rewrite
# Example Response
Status: 200 OK
{
  "status": 0,
  "data": [
    {
      "_modified_unix": 1617248472.0224,
      "_created_unix": 1617084623.9334,
      "order": 1,
      "last": false,
      "top": 0,
      "waf": {
        "rule_sets": [
          7,
          8,
          6
        ]
      },
      "enable_rule": true,
      "id": 1,
      "locked_rule": true,
      "comment": ""
    }
  ]
}

# Modify the http application rewrite rule

# Uri
PUT /admin-api/applications/http/{app_id}/phases/rewrite/rules/{rule_id}
# Json Body Parameters
{
  "waf": {
    "rule_sets": [
      7,
      8,
      6
    ]
  },
  "enable_rule": true,
  "locked_rule": true,
  "comment": "modify the rule"
}
# Example Request
# Shell
curl -X PUT \
  -H "API-token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  http://{admin-site}/admin-api/applications/http/1/phases/rewrite/rules/1 \
  -d '{
    "comment": "modify the rule"
  }'
# Example Response
Status: 200 OK
{"status": 0}