page-rule

This command corresponds to the functions on the page of page rules.

Usage: oredge page-rule ACTION [OPTIONS]

ACTION:
    create
    list
    show
    modify
    delete

GLOBAL OPTIONS:
    --help
    --show-api                         print restful api request.
    --json                             print json format.
    --config                           specify config file, default is ~/.oredge/config.

Create a page rule

Usage: oredge rule create [http] [OPTIONS]

OPTIONS:
    --http string                      application http id.
    --action json                      action, can add multiple times.
    --cache json                       cache.
    --comment string                   comment.
    --condition json                   condition, can add multiple times.
    --content json                     content.
    --last bool                        last, true or false.
    --order integer                    order.
    --proxy json                       proxy.
    --waf json                         waf.

GLOBAL OPTIONS:
    --help
    --show-api                         print restful api request.
    --json                             print json format.
    --config                           specify config file, default is ~/.oredge/config.

For how to specify a page rule, check rule definition part.

Arguments definition

--http "http id"

Specify to which HTTP application the rule is created.

You can specify it in two method

    oredge rule create 1

or

    oredge rule create --http 1

--comment "description string"

You can add a description to this rule

--condition "json string"

This parameter can be used to add multiple conditions to hit the rule.

The condition is a json string. Check the detailed description and examples.

--action "json string"

This parameter can be used to add multiple actions to the request.

The action is a json string. Check the detailed description and examples.

--last "true"

Skip any subsequent page rules when this rule matches, default is false.

--order position

The order of the rule

--content "json"

This parameter set the static content of the rule.

Example:

> oredge create page-rule 1 --content '{"content":{"favicon":12}}'

ID: 1-1

--cache "json"

This parameter configure the cache of the rule. Check the detailed description and examples.

--proxy "json string"

This parameter can be used to add proxy to the specified upstream. The proxy is a json string.

Check the detailed description and examples.

--waf "json string"

This parameter can be used to add waf configuration of the rule.

The waf is a json string.

Example:

oredge create page-rule 1 --waf '{"rule_sets":[6,8,14,15],"action":"log","threshold_score":100}' \
    --condition '{"variable":{"name":"uri"},"operator":{"name":"eq"},"values":[{"type":"str","val":"/a/b"}]}'

List page rules

Usage: oredge rule list [http] [OPTIONS]

OPTIONS:
    --page integer                     page, 1(default).
    --page-size integer                page size, 20(default).
    --http integer                     http id.

GLOBAL OPTIONS:
    --help
    --show-api                         print restful api request.
    --json                             print json format.
    --config                           specify config file, default is ~/.oredge/config.

Example

# oredge rule list 892
ID          CREATE TIME            MODIFY TIME
892-1551    2021-07-15 07:09:59    2021-07-15 07:09:59

Get details of a page rule

Usage: oredge rule show [id] [OPTIONS]

OPTIONS:
    --id integer                       id.

GLOBAL OPTIONS:
    --help
    --show-api                         print restful api request.
    --json                             print json format.
    --config                           specify config file, default is ~/.oredge/config.

Example

# oredge rule show 892-1551
ID         : 892-1551
CREATE TIME: 2021-07-15 07:09:59
MODIFY TIME: 2021-07-15 07:09:59

Modify a page rule

Usage: oredge rule modify [id] [OPTIONS]

OPTIONS:
    --id integer                       id.
    --action json                      action, can add multiple times.
    --cache json                       cache.
    --comment string                   comment.
    --condition json                   condition, can add multiple times.
    --content json                     content.
    --last bool                        last, true or false.
    --order integer                    order.
    --proxy json                       proxy.
    --waf json                         waf.


GLOBAL OPTIONS:
    --help
    --show-api                         print restful api request.
    --json                             print json format.
    --config                           specify config file, default is ~/.oredge/config.

Example

# oredge rule modify 892-1551 --condition 'xxx'
OK

Delete a page rule

Usage: oredge rule delete [id] [OPTIONS]

OPTIONS:
    --id integer                       id.

GLOBAL OPTIONS:
    --help
    --show-api                         print restful api request.
    --json                             print json format.
    --config                           specify config file, default is ~/.oredge/config.

Example

# oredge rule delete 892-1551
OK

Rule definition

A page rule is basically constructed by a condition part and an action part.

Condition

A condition is formed by 3 parts, variable, operator, values. For example, a condition like var1 equals 3 has:

  • variable var1: this can be a user variable, or a global variable defined in advance, or you can choose one of the builtin variables list;
  • operator equals: choose one which suits your need in operators list
  • value 3: value part can be specified by type, check value definition

You can have multiple condition items.

name type required description
variable object yes see variable definition
operator object yes see operator definition
values array yes an array of value, see value definition
caseless bool yes case-insensitive

Variable definition

name type required description
name string no variable name, see builtin variable list
user_var integer no user variable id
global_var integer no global variable id
args string no some variables needs args, see builtin variable list

Note: only one of name, user_var, global_var must be set.

Builtin variable list

name need args args operators description
uri no eq,ne,lt,le,gt,ge,contains,contains-word,prefix,suffix,!contains,!contains-word,!prefix,!suffix URI
uri-arg yes string eq,ne,lt,le,gt,ge,contains,contains-word,prefix,suffix,!contains,!contains-word,!prefix,!suffix,==,!=,<,<=,>,>=,is-empty,!is-empty URI argument
uri-seg yes integer eq,ne,lt,le,gt,ge,contains,contains-word,prefix,suffix,!contains,!contains-word,!prefix,!suffix,==,!=,<,<=,>,>=,is-empty,!is-empty URI segment
query-string no eq,ne,lt,le,gt,ge,contains,contains-word,prefix,suffix,!contains,!contains-word,!prefix,!suffix Query string
sorted-query-string no eq,ne,lt,le,gt,ge,contains,contains-word,prefix,suffix,!contains,!contains-word,!prefix,!suffix Sorted URI argument
host no eq,ne,lt,le,gt,ge,contains,contains-word,prefix,suffix,!contains,!contains-word,!prefix,!suffix Host
req-method no eq,ne Request method
req-cookie yes string eq,ne,lt,le,gt,ge,contains,contains-word,prefix,suffix,!contains,!contains-word,!prefix,!suffix,==,!=,<,<=,>,>=,is-empty,!is-empty Request cookie
req-header yes string eq,ne,lt,le,gt,ge,contains,contains-word,prefix,suffix,!contains,!contains-word,!prefix,!suffix,==,!=,<,<=,>,>=,is-empty,!is-empty Request header
scheme no eq,ne Scheme
server-port no ==,!=,<,<=,>,>= Server Port
server-addr no ~~,!~~,eq,ne,lt,le,gt,ge,contains,contains-word,prefix,suffix,!contains,!contains-word,!prefix,!suffix Server address
first-x-forwarded-addr no ~~,!~~,eq,ne,lt,le,gt,ge,contains,contains-word,prefix,suffix,!contains,!contains-word,!prefix,!suffix First address in X-Forwarded-For
last-x-forwarded-addr no ~~,!~~,eq,ne,lt,le,gt,ge,contains,contains-word,prefix,suffix,!contains,!contains-word,!prefix,!suffix Last address in X-Forwarded-For
user-agent no eq,ne,lt,le,gt,ge,contains,contains-word,prefix,suffix,!contains,!contains-word,!prefix,!suffix,==,!=,<,<=,>,>=,is-empty,!is-empty User agent
User agent is mobile no is-true,!is-true User agent is mobile
client-continent yes string eq,ne Client continent
client-country yes string eq,ne Client country/region
client-province yes string eq,ne Client provinces (China)
client-city yes string eq,ne Client city
client-addr no ~~,!~~,eq,ne,lt,le,gt,ge,contains,contains-word,prefix,suffix,!contains,!contains-word,!prefix,!suffix Client address
ssl-client-s-dn no eq,ne,lt,le,gt,ge,contains,contains-word,prefix,suffix,!contains,!contains-word,!prefix,!suffix,==,!=,<,<=,>,>=,is-empty,!is-empty SSL Client Subject DN

Operator definition

name type required description
name string yes the name of the operator, see operator list

Operator list

Different operator support different value types.

operator value type
eq str,rx,wc
ne str,rx,wc
lt str
le str
gt str
ge str
contains str,rx,wc
contains-word str,rx,wc
prefix str,rx,wc
suffix str,rx,wc
!contains str,rx,wc
!contains-word str,rx,wc
!prefix str,rx,wc
!suffix str,rx,wc
== str
!= str
< str
<= str
> str
>= str
is-empty
!is-empty
is-true
!is-true
~~ netaddr,ip-list
!~~ netaddr,ip-list

Value definition

name type required description
type string yes str,rx,wc,netaddr,uv,global-uv,ip-list, see operator list
val string yes

Condition examples

  1. uri example
> oredge create page-rule 1 \
    --condition '{"variable":{"name":"uri"},"operator":{"name":"eq"},"values":[{"type":"str","val":"/a/b"}]}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'
ID: 1-1

  1. uri-arg example
> oredge create page-rule 1 \
    --condition '{"operator":{"name":"eq"},"variable":{"name":"uri-arg","args":"foo"},"values":[{"type":"str","val":"bar"}]}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1

  1. uri-seg example
> oredge create page-rule 1 \
    --condition '{"variable":{"name":"uri-seg","args":"1"},"operator":{"name":"eq"},"values":[{"type":"str","val":"foo"}]}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1

  1. query-string example
> oredge create page-rule 1 \
    --condition '{"variable":{"name":"query-string"},"operator":{"name":"prefix"},"values":[{"type":"str","val":"foo"}]}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
  1. sorted-query-string example
> oredge create page-rule 1 \
    --condition '{"variable":{"name":"sorted-query-string"},"values":[{"type":"str","val":"foo"}],"operator":{"name":"prefix"}}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
  1. host example
> oredge create page-rule 1 \
    --condition '{"variable":{"name":"host"},"values":[{"type":"str","val":"foo"}],"operator":{"name":"eq"},"caseless":true}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
  1. req-method example
> oredge create page-rule 1 \
    --condition '{"operator":{"name":"eq"},"values":[{"type":"str","val":"GET"}],"caseless":false,"variable":{"name":"req-method"}}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
  1. req-cookie example
> oredge create page-rule 1 \
    --condition '{"operator":{"name":"eq"},"values":[{"type":"str","val":"bar"}],"variable":{"name":"req-cookie","args":"foo"}}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
  1. req-header example
> oredge create page-rule 1 \
    --condition '{"operator":{"name":"eq"},"values":[{"type":"str","val":"bar"}],"variable":{"name":"req-header","args":"foo"}}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
  1. scheme example
> oredge create page-rule 1 \
    --condition '{"operator":{"name":"eq"},"values":[{"type":"str","val":"http"}],"variable":{"name":"scheme"}}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
  1. server-port example
> oredge create page-rule 1 \
    --condition '{"operator":{"name":"=="},"values":[{"type":"str","val":"80"}],"variable":{"name":"server-port"}}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
  1. server-addr example
> oredge create page-rule 1 \
    --condition '{"operator":{"name":"eq"},"values":[{"type":"str","val":"192.168.0.1"}],"variable":{"name":"server-addr"}}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
  1. first-x-forwarded-addr example
> oredge create page-rule 1 \
    --condition '{"operator":{"name":"~~"},"values":[{"type":"netaddr","val":"192.168.0.1"}],"variable":{"name":"first-x-forwarded-addr"}}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
> oredge create page-rule 1 \
    --condition '{"operator":{"name":"~~"},"values":[{"type":"ip-list","val":"15"}],"variable":{"name":"first-x-forwarded-addr"}}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
  1. last-x-forwarded-addr example
> oredge create page-rule 1 \
    --condition '{"operator":{"name":"~~"},"values":[{"type":"netaddr","val":"192.168.0.1"}],"variable":{"name":"last-x-forwarded-addr"}}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
> oredge create page-rule 1 \
    --condition '{"operator":{"name":"~~"},"values":[{"type":"ip-list","val":"15"}],"variable":{"name":"last-x-forwarded-addr"}}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
  1. user-agent example
> oredge create page-rule 1 \
    --condition '{"operator":{"name":"eq"},"values":[{"type":"str","val":"foo"}],"variable":{"name":"user-agent"}}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
  1. ua-is-mobile example
> oredge create page-rule 1 \
    --condition '{"operator":{"name":"is-true"},"variable":{"name":"ua-is-mobile"}}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
> oredge create page-rule 1 \
    --condition '{"operator":{"name":"!is-true"},"variable":{"name":"ua-is-mobile"}}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
  1. client-continent example
> oredge create page-rule 1 \
    --condition '{"operator":{"name":"eq"},"variable":{"name":"client-continent"},"values":[{"type":"str","val":"AF"}]}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
  1. client-country example
> oredge create page-rule 1 \
    --condition '{"operator":{"name":"eq"},"values":[{"type":"str","val":"UK"}],"variable":{"name":"client-country"}}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
  1. client-province example
> oredge create page-rule 1 \
    --condition '{"values":[{"type":"str","val":"Beijing"}],"operator":{"name":"eq"},"variable":{"name":"client-province"}}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
  1. client-city example
> oredge create page-rule 1 \
    --condition '{"operator":{"name":"eq"},"values":[{"type":"str","val":"London"}],"variable":{"name":"client-city"}}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
  1. client-addr example
> oredge create page-rule 1 \
    --condition '{"operator":{"name":"eq"},"values":[{"type":"str","val":"192.168.1.1"}],"variable":{"name":"client-addr"}}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
  1. ssl-client-s-dn example
> oredge create page-rule 1 \
    --condition '{"operator":{"name":"eq"},"values":[{"type":"str","val":"foo.com"}],"variable":{"name":"ssl-client-s-dn"}}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
  1. global user variable example
> oredge create page-rule 1 \
    --condition '{"operator":{"name":"eq"},"values":[{"type":"str","val":"foo"}],"variable":{"global_var":7}}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
  1. gateway-cluster example
> oredge create page-rule 1 \
    --condition '{"operator":{"name":"eq"},"values":[{"type":"str","val":"1"}],"variable":{"name":"gateway-cluster"}}' \
    --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1

Action

name type description
type string action type
? object the name is equal to value of type,
for example {type: "set-uri", set-uri: {...}}

You can also use custom

Available builtin action list

set-uri

Set URI

name type description
uri string

Example:

> oredge create page-rule 1 --action '{ "type": "set-uri", "set-uri": { "uri": "/foo/bar" } }'

ID: 1-1
add-uri-prefix

Add URI prefix

name type description
value string

Example:

> oredge create page-rule 1 --action '{"type":"add-uri-prefix","add-uri-prefix":{"value":"/foo"}}'

ID: 1-1
rm-uri-prefix

Remove URI prefix

name type description
value string

Example:

> oredge create page-rule 1 --action '{"type":"rm-uri-prefix","rm-uri-prefix":{"value":"/foo"}}'

ID: 1-1
rm-uri-seg

Remove URI segment

name type description
value integer

Example:

> oredge create page-rule 1 --action '{"type":"rm-uri-seg","rm-uri-seg":{"index":1}}'

ID: 1-1
set-req-header

Set request header

name type description
header string
value string

Example:

> oredge create page-rule 1 --action '{"type":"set-req-header","set-req-header":{"header":"foo","value":"bar"}}'

ID: 1-1
add-req-header

Add request header

name type description
header string
value string

Example:

> oredge create page-rule 1 --action '{"type":"add-req-header","add-req-header":{"header":"foo","value":"bar"}}'

ID: 1-1
set-uri-arg

Set URI argument

name type description
arg string
value string

Example:

> oredge create page-rule 1 --action '{"type":"set-uri-arg","set-uri-arg":{"arg":"foo","value":"bar"}}'

ID: 1-1
add-uri-arg

Add URI argument

name type description
arg string
value string

Example:

> oredge create page-rule 1 --action '{"type":"add-uri-arg","add-uri-arg":{"arg":"foo","value":"bar"}}'

ID: 1-1
rm-uri-arg

Remove URI argument

name type description
name string

Example:

> oredge create page-rule 1 --action '{"type":"rm-uri-arg","rm-uri-arg":{"name":"foo"}}'

ID: 1-1
set-proxy-uri

Set proxy URI

name type description
value string
arg string

Example:

> oredge create page-rule 1 --action '{"type":"set-proxy-uri","set-proxy-uri":{"uri":"/foo"}}'

ID: 1-1
rewrite-proxy-uri-prefix

Rewrite proxy URI prefix

name type description
prefix string
replacement string

Example:

> oredge create page-rule 1 --action '{"type":"rewrite-proxy-uri-prefix","rewrite-proxy-uri-prefix":{"prefix":"/foo","replacement":"/bar"}}'

ID: 1-1
set-proxy-header

Set proxy header

name type description
header string
value string
el_var string

Example:

> oredge create page-rule 1 --action '{"type":"set-proxy-header","set-proxy-header":{"header":"Host","value":"foo"}}'

ID: 1-1
append-proxy-header-value

Append proxy header value

name type description
header string
value string
el_var string

Example:

> oredge create page-rule 1 --action '{"type":"append-proxy-header-value","append-proxy-header-value":{"el_var":"client-addr","header":"X-Forwarded-For"}}'

ID: 1-1
enable-proxy-cache-revalidate

Enable proxy cache revalidate

name type description
enabled string

Example:

> oredge create page-rule 1 --action '{"type":"enable-proxy-cache-revalidate","enable-proxy-cache-revalidate":{"enabled":true}}'

ID: 1-1
set-proxy-cache-use-stale

Use stale proxy cache

name type description
value string

Example:

> oredge create page-rule 1 --action '{"type":"set-proxy-cache-use-stale","set-proxy-cache-use-stale":{"args":["error","timeout","invalid_header","updating","http_500","http_502","http_503","http_504","http_403","http_404","http_429"]}}'

ID: 1-1
redirect

Redirect

name type description
args string
code string
host string
port string
scheme string
url string

Example:

> oredge create page-rule 1 --action '"type":"redirect","redirect":{"scheme":"http","port":80,"url":"/foo","args":"foo=bar","host":"foo.com","code":302}}'

ID: 1-1
print

Print

name type description
content_type string

Example:

> oredge create page-rule 1 --action '{"type":"print","print":{"msg":"<!doctype html>\n<html>\n<head>\n  <title>Response</title>\n</head>\n<body>\n</body>\n</html>","content_type":"text/html"}}'

ID: 1-1
exit

Exit

name type description
code string

Example:

> oredge create page-rule 1 --action '{"type":"exit","exit":{"code":204}}'

ID: 1-1
send-static-file

Return static file

name type description
start_index string
end_index string

Example:

> oredge create page-rule 1 --action '{"type":"send-static-file","send-static-file":{"start_index":1,"end_index":2}}'

ID: 1-1
sleep

sleep

name type description
time string

Example:

> oredge create page-rule 1 --action '{"type":"sleep","sleep":{"time":2}}'

ID: 1-1
limit-req-rate

Limit request rate

name type description
edge_captcha_clearance_time string
error_page_status_code string
hcaptcha_clearance_time string
limit_key string
rate_reject string
rate_reject_unit string
rate_shape string
rate_shape_unit string
reject_action string

Example:

> oredge create page-rule 1 --action '{"type":"limit-req-rate","limit-req-rate":{"limit_key":"client-addr","rate_shape":1,"rate_shape_unit":"r/s","rate_reject":1,"rate_reject_unit":"r/s","reject_action":"error_page","error_page_status_code":503,"hcaptcha_clearance_time":60,"edge_captcha_clearance_time":60}}'

ID: 1-1
limit-req-count

Limit request count

name type description
count_reject string
count_time_window string
limit_key string

Example:

> oredge create page-rule 1 --action '{"type":"limit-req-count","limit-req-count":{"limit_key":"client-addr","count_reject":10,"count_time_window":1}}'

ID: 1-1
block-req

Block request

name type description
block_threshold string
block_time string
limit_key string
observe_interval string
rate_reject string
rate_reject_unit string
rate_shape string
rate_shape_unit string

Example:

> oredge create page-rule 1 --action '{"type":"block-req","block-req":{"limit_key":"client-addr","rate_shape":1,"rate_shape_unit":"r/s","rate_reject":1,"rate_reject_unit":"r/s","block_threshold":2,"observe_interval":5,"block_time":60}}'

ID: 1-1
set-resp-header

Set response header

name type description
name string
value string
el_var_arg string

Example:

> oredge create page-rule 1 --action '{"type":"set-resp-header","set-resp-header":{"name":"foo","value":"bar"}}'

ID: 1-1
add-resp-header

Add response header

name type description
name string
value string
el_var_arg string

Example:

> oredge create page-rule 1 --action '{"type":"add-resp-header","add-resp-header":{"name":"foo","value":"bar"}}'

ID: 1-1
rm-resp-header

Remove response header

name type description
name string

Example:

> oredge create page-rule 1 --action '{"type":"rm-resp-header","rm-resp-header":{"name":"foo"}}'

ID: 1-1
apply-std-mime-types
name type description
force bool

Example:

> oredge create page-rule 1 --action '{"type":"apply-std-mime-types","apply-std-mime-types":{"force":true}}'

ID: 1-1
expires
name type description
force bool
max_age integer
max_age_unit string

Example:

> oredge create page-rule 1 --action '{"type":"expires","expires":{"max_age":1,"max_age_unit":"hour","force":true}}'

ID: 1-1
name type description
el_var_arg string
http_only integer
max_age string
max_age_unit string
name string
path string
value string

Example:

> oredge create page-rule 1 --action '{"type":"set-resp-cookie","set-resp-cookie":{"http_only":true,"max_age":1,"max_age_unit":"hour","name":"foo","el_var":"userid","domain":"bar.com","path":"/foo/bar"}}'

ID: 1-1
limit-resp-data-rate
name type description
rate string
rate_unit integer

Example:

> oredge create page-rule 1 --action '{"type":"limit-resp-data-rate","limit-resp-data-rate":{"rate_unit":"kB/s","rate":10}}'

ID: 1-1
user-code
name type description
el string

Example:

> oredge create page-rule 1 --action '{"type":"user-code","user-code":{"el":"my Str $s = \"hello world\";"}}'

ID: 1-1
enable-openidc-authentication
name type description
client_id string
client_secret string
discovery string
logout_path string
redirect_uri string
scope string
ssl_verify string
timeout string
timeout_unit string
token_endpoint_auth_method string

Example:

> oredge create page-rule 1 --action '{"type":"enable-openidc-authentication","enable-openidc-authentication":{"token_endpoint_auth_method":"client_secret_basic","scope":"openid","ssl_verify":false,"timeout":1000,"timeout_unit":"ms","logout_path":"/logout","client_id":"foo","client_secret":"bar","discovery":"http://foo.com/a/b","redirect_uri":"http://foo.com/c/d"}}'

ID: 1-1
enable-websocket

Example:

> oredge create page-rule 1 --action '{"type":"enable-websocket","enable-websocket":{}}'

ID: 1-1
enable-gateway-brotli
name type description
enabled bool

Example:

> oredge create page-rule 1 --action '{"type":"enable-gateway-brotli","enable-gateway-brotli":{"enabled":true}}'

ID: 1-1
enable-gateway-gzip
name type description
enabled bool

Example:

> oredge create page-rule 1 --action '{"type":"enable-gateway-gzip","enable-gateway-gzip":{"enabled":true}}'

ID: 1-1
intercept-upstream-errors
name type description
enabled bool

Example:

> oredge create page-rule 1 --action '{"type":"intercept-upstream-errors","intercept-upstream-errors":{"enabled":true}}'

ID: 1-1
errlog
name type description
level string
msg string

Example:

> oredge create page-rule 1 --action '{"type":"errlog","errlog":{"level":"error","msg":"foo"}}'

ID: 1-1
set-brotli-types
name type description
types array

Example:

> oredge create page-rule 1 --action '{"type":"set-brotli-types","set-brotli-types":{"types":["foo", "bar"]}}'

ID: 1-1
set-gzip-types
name type description
types array

Example:

> oredge create page-rule 1 --action '{"type":"set-gzip-types","set-gzip-types":{"types":["foo","bar"]}}'

ID: 1-1
set-max-body-size
name type description
value integer
unit string

Example:

> oredge create page-rule 1 --action '{"type":"set-max-body-size","set-max-body-size":{"value":1,"unit":"mB"}}'

ID: 1-1
set-var
name type description
global_var_id integer
value string

Example:

> oredge create page-rule 1 --action '{"type":"set-var","set-var":{"global_var_id":5,"value":"yes"}}'

ID: 1-1
set-error-page

Example:

> oredge create page-rule 1 --action '{"type":"set-error-page","set-error-page":{"type":"raw-content","content_type":"text/html; charset=utf8","content":"<!doctype html>\n<html lang=\"en\">\n<head>\n  <title>404 NOT FOUND</title>\n</head>\n<body>\n</body>\n</html>","status":[403,404,500,502,503,504]}}'

ID: 1-1
disable-req-buffering

Example:

> oredge create page-rule 1 --action '{"type":"disable-req-buffering","disable-req-buffering":{}}'

ID: 1-1
enable-basic-authentication

Example:

> oredge create page-rule 1 --action '{"type":"enable-basic-authentication","enable-basic-authentication":{"app_auth_id":3}}'

ID: 1-1
Using custom global action

You can apply predefined global action by specified the id.

> oredge create page-rule 1 --action '{"global_action_id":1}'

ID: 1-1

Cache

name type description
browserCache bool
browser_ttl integer
browser_ttl_unit string
cluster_hash bool Use consistent hashing to share the response cache in each gateway cluster.
default_ttls array
cache_key array the key of cache content, see cache key list
enableDefaultTtl bool When disabled (which is the default), we won’t cache responses without any cache controlling headers like Expires and Cache-Control. When enabled, we will cache these responses with force. If the backend servers explicitly disable caching, then the cache will still be bypassed even when this option is enabled.

Cache key list

name need args
uri no
uri-arg yes
uri-seg yes
query-string no
sorted-query-string no
req-method no
req-cookie yes
req-header yes
scheme no
first-x-forwarded-addr no
last-x-forwarded-addr no
user-agent no
ua-is-mobile no
client-continent no
client-province no
client-city no
client-isp no
ssl-client-s-dn no

Cache examples

> oredge create page-rule 1 --cache '{"cache_key":[{"name":"uri"},{"name":"query-string"},{"name":"uri-seg","args":"1"}],"enableDefaultTtl":true,"enforce_cache":false,"cluster_hash":true,"enableConvertHead":true,"enable_global":true,"browserCache":true,"browser_ttl":1,"browser_ttl_unit":"min","disable_convert_head":false,"default_ttls":[{"ttl":1,"ttl_unit":"min","status":200}]}' \
    --proxy '{"upstream":[{"cluster":1836,"weight":1,"upstream":null}],"backup_upstream":[],"upstream_el_code":"","balancer":{"algorithm":"roundrobin","variables":[]},"useSameBalancingPolicy":true,"sticky":{"enable":false,"key":"Edge-Sticky","level":"upstream","ttl":0,"mode":"none"},"retry_condition":["error","timeout","invalid_header","http_500","http_502","http_504"],"connect_timeout":6,"connect_timeout_unit":"s","send_timeout":6,"send_timeout_unit":"s","read_timeout":6,"read_timeout_unit":"s","retries":1,"layer_policy":null,"balancer2":null}'

Proxy

name type description
balancer object balancer algorithm
upstream object
backup_upstream object
upstream_el_code string you can use edgelang instead of upstream and backup_upstream
connect_timeout integer
connect_timeout_unit string s,ms
read_timeout integer
read_timeout_unit string s,ms
send_timeout integer
send_timeout_unit string s,ms
layer_policy integer
retries integer set to -1 means same as the number of upstream nodes.
retry_condition array array of string, value must be error,timeout,invalid_header,http_500,http_502,http_504
sticky object

balancer

name type description
algorithm string one of hash,chash,roundrobin
variables array if algorithm is hash or chash, this field is required.

Variables is an array of object. The object is like this: {"name" : "uri" } or {"name" : "uri-arg", "args" : "foo"} (for variable need arguments).

All available variables are listed here:

name need args
uri no
uri-arg yes
uri-seg yes
query-string no
sorted-query-strin no
req-method no
req-cookie yes
req-header yes
scheme no
first-x-forwarded-addr no
last-x-forwarded-addr no
user-agent no
ua-is-mobile no
client-continent no
client-province no
client-city no
client-isp no
ssl-client-s-dn no

upstream

name type description
cluster integer upstream id
global_cluster integer global upstream id
k8s_cluster integer k8s upstream id
global_k8s_cluster integer global k8s upstream id
weight integer weight of the upstream

sticky

name type description
enable bool
key string
level string upstream,server
ttl integer

Proxy examples

  1. proxy a upstream
> oredge create page-rule 1 --proxy '{"upstream":[{"cluster":1836,"weight":1}],"backup_upstream":[],"upstream_el_code":"","balancer":{"algorithm":"roundrobin","variables":[]},"useSameBalancingPolicy":true,"sticky":{"enable":false,"key":"Edge-Sticky","level":"upstream","ttl":0,"mode":"none"},"retry_condition":["error","timeout","invalid_header","http_500","http_502","http_504"],"connect_timeout":6,"connect_timeout_unit":"s","send_timeout":6,"send_timeout_unit":"s","read_timeout":6,"read_timeout_unit":"s","retries":1,"layer_policy":null,"balancer2":null}' \
    --condition '{"variable":{"name":"uri"},"operator":{"name":"eq"},"values":[{"type":"str","val":"/a/b"}]}'

  1. proxy a global upstream
> oredge create page-rule 1 --proxy '{"upstream":[{"global_cluster":1836,"weight":1}],"backup_upstream":[],"upstream_el_code":"","balancer":{"algorithm":"roundrobin","variables":[]},"useSameBalancingPolicy":true,"sticky":{"enable":false,"key":"Edge-Sticky","level":"upstream","ttl":0,"mode":"none"},"retry_condition":["error","timeout","invalid_header","http_500","http_502","http_504"],"connect_timeout":6,"connect_timeout_unit":"s","send_timeout":6,"send_timeout_unit":"s","read_timeout":6,"read_timeout_unit":"s","retries":1,"layer_policy":null,"balancer2":null}' \
    --condition '{"variable":{"name":"uri"},"operator":{"name":"eq"},"values":[{"type":"str","val":"/a/b"}]}'

  1. proxy a k8s upstream
> oredge create page-rule 1 --proxy '{"upstream":[{"k8s_cluster":1836,"weight":1}],"backup_upstream":[],"upstream_el_code":"","balancer":{"algorithm":"roundrobin","variables":[]},"useSameBalancingPolicy":true,"sticky":{"enable":false,"key":"Edge-Sticky","level":"upstream","ttl":0,"mode":"none"},"retry_condition":["error","timeout","invalid_header","http_500","http_502","http_504"],"connect_timeout":6,"connect_timeout_unit":"s","send_timeout":6,"send_timeout_unit":"s","read_timeout":6,"read_timeout_unit":"s","retries":1,"layer_policy":null,"balancer2":null}' \
    --condition '{"variable":{"name":"uri"},"operator":{"name":"eq"},"values":[{"type":"str","val":"/a/b"}]}'

  1. proxy a global k8s upstream
> oredge create page-rule 1 --proxy '{"upstream":[{"global_k8s_cluster":1836,"weight":1}],"backup_upstream":[],"upstream_el_code":"","balancer":{"algorithm":"roundrobin","variables":[]},"useSameBalancingPolicy":true,"sticky":{"enable":false,"key":"Edge-Sticky","level":"upstream","ttl":0,"mode":"none"},"retry_condition":["error","timeout","invalid_header","http_500","http_502","http_504"],"connect_timeout":6,"connect_timeout_unit":"s","send_timeout":6,"send_timeout_unit":"s","read_timeout":6,"read_timeout_unit":"s","retries":1,"layer_policy":null,"balancer2":null}' \
    --condition '{"variable":{"name":"uri"},"operator":{"name":"eq"},"values":[{"type":"str","val":"/a/b"}]}'