Tencent Cloud EdgeOne

Tencent Cloud EdgeOne
Rule Engine
Product Documentation©2013-2022 Tencent Cloud. All rights reserved.

Page 1 of 23

Tencent Cloud EdgeOne

Copyright Notice©2013-2024 Tencent Cloud. All rights reserved.
Copyright in this document is exclusively owned by Tencent Cloud. You must not reproduce, modify, copy or distributein any way, in whole or in part, the contents of this document without Tencent Cloud's the prior written consent.
Trademark Notice

All trademarks associated with Tencent Cloud and its services are owned by Tencent Cloud Computing (Beijing)
Company Limited and its affiliated companies. Trademarks of third parties referred to in this document are owned bytheir respective proprietors.
Service Statement
This document is intended to provide users with general information about Tencent Cloud's products and services
only and does not form part of Tencent Cloud's terms and conditions. Tencent Cloud's products or services are
subject to change. Specific products and services and the standards applicable to them are exclusively provided for in
Tencent Cloud's applicable terms and conditions.

©2013-2022 Tencent Cloud. All rights reserved.

Page 2 of 23

Tencent Cloud EdgeOne

Contents
Rule Engine
Overview
Supported Matching Types and Actions
Rule Management
variables©2013-2022 Tencent Cloud. All rights reserved.

Page 3 of 23

Tencent Cloud EdgeOne

Rule Engine
Overview：

Last updated 2024-08-01 21:32:16

Overview
The rule engine is designed to meet more flexible and fine-grained business requirements through a rich rule
language. You can customize the match type as needed and apply it to the corresponding operations. Compared tothe configuration of site acceleration, the priority of the rule engine is higher, meaning that the custom policies createdby the rule engine will override the configurations of site acceleration.

Use Cases
Provide custom configurations based on different conditions (subdomain name, path and file extension) when sitelevel configuration in Site Acceleration cannot meet your needs.
Provide basic features (caching and HTTPS) and acceleration features (custom cache key, URL rewrite and HTTP
header modification).

Key Terms
Term

Description

Rule

It defines specific types of requests and the applicable operations.
It defines the logics that identify the requests. The followings are supported.

Conditional
Expression

IF Note 1﻿
ELSE IFELSE

Matching
Condition

It defines the criteria that identifies the requests. The followings are included.
Matching typeOperator
Value

And/Or

Logical AND/OR, which can link multiple conditions.

ActionA wide range of feature configurations that can be applied to hit requests.

©2013-2022 Tencent Cloud. All rights reserved.

Page 4 of 23

Tencent Cloud EdgeOne

Note:
Note 1:
An IF statement can be nested inside another IF statement, indicating that the nested one will be executed only after
the other is met.

Rule Priorities
Range

Description

Site Acceleration

If the same operation is configured for both site acceleration and the rule engine, the rulevs Rule Engine

engine has a higher priority and is the final effective configuration.
If there exist nested IF conditions within an IF statement, the execution of the embedded
IF statement necessitates the fulfillment of the outermost IF condition.
In the event of multiple coequal IF conditions, they are executed in relative order from top

Single rule in therule engine

to bottom. That is, if multiple rules are matched simultaneously, the operations of thelower rules will supersede those of the upper rules.
In the event that IF, Else IF, and Else coexist, upon satisfying any one of the IF or Else IF
conditions, the corresponding operation will be executed and concluded, precluding
further matching of other rules under the current IF condition. If none are met, operations
will be executed in accordance with the Else rule.

Multiple rules in therule engine

The rules are executed in relative order, from top to bottom.
Note: You can place general or coarse-grained rules at the top as the default
configuration and request-specific or finer-grained rules at the bottom.

Note:
There are two scenarios with special execution:
Token authentication will be executed first no matter where it is placed. If a request hits two rules, token authentication
will be executed first, as other operations will be performed only after authentication is passed.
For operations with redirect logic, such as URL redirection and forced HTTPS, their execution method is Break. Thismeans that if the same request encounters both a redirect operation and other operations, the other operations below
will not be executed after the redirect operation is executed.

Example of Rule Priorities
Example One: Nested IF Conditions within IF Matches©2013-2022 Tencent Cloud. All rights reserved.

Page 5 of 23

Tencent Cloud EdgeOne

The current user's node cache TTL rule configuration is as follows, with multiple nested IF conditions present.

The caching behavior of the user-requested URL is activated as follows:©2013-2022 Tencent Cloud. All rights reserved.

Page 6 of 23

Tencent Cloud EdgeOne

When the request URL is: https://test.example.com/example/1.jpg , the file is cached for a duration of
10 minutes.
When the request URL is: https://test.example.com/example/1.mp4 , the file is not subjected to caching.
When the request URL is: https://test.example.com/video/1.jpg , it does not conform to the stipulated
rule.

Example Two: IF Condition Contains Multiple Parallel Else IF Matches
The current user's node cache TTL rule configuration is depicted below, with multiple coequal Else IF conditions
present.

©2013-2022 Tencent Cloud. All rights reserved.

Page 7 of 23

Tencent Cloud EdgeOne

The caching behavior of the user's requested URL will take effect as follows:©2013-2022 Tencent Cloud. All rights reserved.

Page 8 of 23

Tencent Cloud EdgeOne©2013-2022 Tencent Cloud. All rights reserved.

Page 9 of 23

Tencent Cloud EdgeOne

When the request URL is: https://test.example.com/image/1.jpg , the file is cached for a duration of 7
days.
When the request URL is: https://test.example.com/index/1.jsp , the file is not subjected to caching.
When the request URL is: https://test.example.com/admin/1.php , caching is not implemented.

Example Three: Multiple Peer-Level IF Condition Matching
The current user's node cache TTL rule configuration is as follows. In the presence of multiple peer IF conditions, theeffectiveness priority sequence of the subsequent conditions is the highest.

The caching behavior of the user's requested URL is activated as follows:©2013-2022 Tencent Cloud. All rights reserved.

Page 10 of 23

Tencent Cloud EdgeOne

When the request URL is: https://test.example.com/image/1.jpg , the file is cached for a duration of 7
days.
When the request URL is: https://test.example.com/admin/1.php , the file is not subjected to caching.
When the request URL is: https://test.exampel.com/admin/1.jpg , the file is not subjected to caching.
When the request URL is: https://test.exampel.com/index/1.txt , the file adheres to the source site'sCache-Control header settings. In the absence of such a header, it complies with the default caching policy of
EdgeOne.

©2013-2022 Tencent Cloud. All rights reserved.

Page 11 of 23

Tencent Cloud EdgeOne

Supported Matching Types and Actions：

Last updated 2024-01-02 10:42:44

Supported Matching Types
Supported matching types are listed in the following tables.
Note
1. URL Path and URL Full support wildcard match. If the URL Path is /foo/*/bar , both/foo/example/bar and /foo/demo/bar are valid values.
2. URL Path, URL Full, query string, file extension,file name and HTTP request header support enabling ignoring case
(it is disabled by default).
Type

Description

Sample values

HOST

Request Hostwww.example.com
If you need to match the /example/foo/bar
Path, you can fill in: /example/foo/bar ;URL Path

Request URL path

If you need to match the /example
directory and all files under the directory, you
can fill in: /example/* .

URL Full

Complete content of the request
URL

https://www.example.com/foo

Query string

Query string in the request URL

Parameter name: key
Parameter value: value

File extension

File extension (file extension) of therequest content

jpg, png, cssFile name

File name of the request content

foo.txt

HTTP request
headerHTTP request header

HTTP request header name: nameHTTP request header value: value

Client geo location

Country/region of the client IP

United States

Request protocol

Requested protocol type

HTTPS or HTTPAll

Any site request

N/A©2013-2022 Tencent Cloud. All rights reserved.

Page 12 of 23

Tencent Cloud EdgeOne

Operators
Type

Description

Equal toThe request is equal to a specified value (value of the matching type).

Not equal to

The request is not equal to a specified value (value of the matching type).

Exist

A specified value exists in the request (HTTP header name or query parametername).

Not exist

A specified value does not exist in the request (HTTP header name or queryparameter name).

Regular expression
matching

URL Path and URL Full support Google RE2 regular expression matching.

Supported Actions
Actions refer to a series of feature configurations performed after the requests hit the conditions. The supported
actions and matching types are listed in the following tables.

Cache configuration
ActionNode Cache TTL

Description
By configuring the cache TTL, you can
optimize node cache to improve resourceloading and update resources in a timely
manner.

Browser Cache TTL

Custom Cache Key

Supported Matching TypesHOST
URL FULLURL Path
File name
File extension

By adjusting the cache period of

HOST
URL FULL

resources in browsers, you can optimize
the browser cache and increase theloading speed of the requested

URL Path
File name
File extension

resources.

Query string
Client geo location

A cache key can be customized to suit
your needs by setting the query string,
HTTP header and URL case, so thatHOSTURL FULLURL Path
File name©2013-2022 Tencent Cloud. All rights reserved.

Page 13 of 23

Tencent Cloud EdgeOne

requested resources can be loaded
faster.

File extension
Query string
HTTP Request Header
Client geo location
HOST

Status Code Cache
TTL

You can specify a TTL period for origin
response status codes, allowing the node
to directly respond with non-2XX codes.

Cached resources are validated via
Cache Prefresh

Offline Cache

origin-pull before expiration, so that yoursite can respond to requests more
rapidly.

URL FULLURL Path
File name
File extension
Query stringHOST
URL FULLURL Path
File name
File extension

After offline caching is enabled, whenyour origin fails, and resources cannot be

HOST
URL FULLURL Pathpulled through origin-pull normally,
resources cached on nodes (evenexpired resources) can be used until theorigin recovers.

File name
File extension
Query string
HTTP Request Header
Client geo location

Network optimization
ActionDescription

Supported Matching Types

HTTP/2 (HTTP 2.0) requests are
HTTP/2

HTTP/3 (QUIC)

supported to accelerate sites andimprove the web performance.
HTTP/3 (QUIC) requests are supported.
HTTP/3 (QUIC) is used to accelerate site
requests and improve data transfer

HOST

HOST

efficiency and security.

WebSocket

Maximum Upload Size

EdgeOne supports the WebSocket
protocol that allows the server toproactively send data to the client.

HOST

The maximum upload size is the
maximum data volume that can be

HOST
URL FULL©2013-2022 Tencent Cloud. All rights reserved.

Page 14 of 23

Tencent Cloud EdgeOne

uploaded in a single client request. You

URL Path

can restrict it to improve the data transfer
efficiency and optimize the networktransfer.

File name
File extension
Query string
HTTP Request Header

Smart Compression can automatically
Smart Compression

compress the resources to Gzip/Brotli
files to reduce the files size and shorten
the resource loading time.

HOST

Smart acceleration refers to smart
dynamic routing acceleration. After thisfeature is enabled, it will detect the node
network latency in real time and use thesmart algorithm to select the optimal
Smart Accelerationtransfer path, so as to handle both staticand dynamic client requests more
quickly, stably, and securely.

HOST

Smart dynamic routing minimizes
problems such as high network latency,
connection errors, and request failures.
Request origin-pull over the HTTP/2
protocol is supported.

HOST

ActionDescription

Supported Matching Types

Forced HTTPS﻿You can use 301 or 302 redirect toredirect HTTP client requests to HTTPS
requests and send them to EdgeOne.

HOST

HTTP/2 Origin-Pull

HTTPS optimization

Force clients such as browsers to
HSTS Configuration﻿

SSL/TLS Security
Configuration﻿establish connections to edge nodes over
HTTPS for global website encryption.
Configure the protocol version and Cipher
suite that are allowed to use when theclient shakes hands with the edge server

HOST

HOST

TLS as needed.
Pre-cached OCSP responses are sent at
OCSP Stapling﻿

the time of TLS handshake to improve theefficiency.

©2013-2022 Tencent Cloud. All rights reserved.

HOST

Page 15 of 23

Tencent Cloud EdgeOne

Origin-Pull HTTPS﻿You can specify the protocol that
EdgeOne uses in the origin-pull request.

HOST

Description

Supported Matching Types

You can customize, add, and delete

HOST
URL FULLURL Path

Modifying HTTP header
ActionModifying HTTP
Response Headersheaders in HTTP responses from nodes
to clients.

File name
File extension
Query string
Client geo location
HOST

The custom header can carry the real
Client IP Header﻿

Client IP Geographical
Location

Modifying HTTP OriginPull Request Headersclient IP to the origin.

The custom header can carry thegeographical location information of theclient IP to the origin.

You can customize, add, and delete
headers in HTTP origin-pull requests
from nodes to the origin.

URL FULLURL Path
File name
File extension
Query string
HTTP Request Header
Client geo location
HOST
Client geo locationHOST
URL FULLURL Path
File name
File extension
Query string
HTTP Request Header
Client geo location

Host Header Rewriting

Host header rewriting enables you torewrite the host header to the actual origin
domain when the origin domain is

HOST
URL FULLURL Pathdifferent from the acceleration domain in
the load balancing task.

File name
File extension
Query string
HTTP Request Header
Client geo location
Request protocol©2013-2022 Tencent Cloud. All rights reserved.

Page 16 of 23

Tencent Cloud EdgeOne

Advanced configuration
ActionAccess URL
Redirection

Description

A node redirects the URL requested by
the client to the destination URL based on
the response status code.

Supported Matching TypesHOST
URL FULLURL Path
File name
File extension
Query string
HTTP Request Header
Client geo location

Token Authentication

Modify Origin

As an access control policy, token

HOST

authentication supports creating rules tovalidate access and filter out
unauthorized access requests. ThisURL FULLURL Path
File nameeffectively prevents your site resourcesfrom being maliciously hotlinked and thus
protects your business.

File extension
Query string
HTTP Request Header

Configuration of primary and secondary

HOST + Any matching type below
URL Pathsources, separate Path, and separate
region Rules for complex origin-pull
strategies.

Client country/region
HTTP Request Header
Query string：

File extension
HOST
Based on specified rules, this feature
rewrites the user request URL received
by the node to the destination URL when

URL FULLURL Path
File namethe node sends the request to the origin
server, which doesn't affect the nodecache key.

File extension
Query string
HTTP Request Header
Client geo location

Controlling Origin-pull

You can specify which part of the query

HOST

Requests

string and Cookie to be included in therequest when it’s forwarded to the origin.

URL FULLURL Path
File name

Origin-Pull URL Rewrite

File extension
Query string
HTTP Request Header
Client geo location©2013-2022 Tencent Cloud. All rights reserved.

Page 17 of 23

Tencent Cloud EdgeOne

HOST
When origin-pull is requested, the redirect
Redirect Following
During Origin-Pullwill be based on the 302/301 status codeof the origin server, and you can specify
the maximum number of redirects (whichis 3 by default and can be 1-5).

URL FULLURL Path
File name
File extension
Query string
HTTP Request Header
Client geo locationHOST
URL FULL

Custom Error Page

You can redirect requests to a custom
error page for specific error status codes
returned by the origin. The redirection is

URL Path
File name
File extension

performed when a 302 is returned.

Query string
HTTP Request Header
Client geo locationHOST
URL FULL

Range GETs

Range GETs can be enabled to reducethe consumption of large file origin-pulls
and response time.

URL Path
File name
File extension
Query string
HTTP Request Header©2013-2022 Tencent Cloud. All rights reserved.

Page 18 of 23

Tencent Cloud EdgeOne

Rule Management：

Last updated 2024-01-25 11:28:53
The console supports a series of icons and buttons to manage rules, for example, sorting, copying, enabling, anddisabling rules, as follows.
Icon/Button

Description

Drags a rule up or down.

Pins a rule to the top.

Pins a rule to the bottom.

Edits a rule.

Creates the same rule as the copied rule.

Deletes a rule.

Searches for a rule by rule name or keyword.

©2013-2022 Tencent Cloud. All rights reserved.

Page 19 of 23

Tencent Cloud EdgeOne

Rule status
Enable: Publishes a rule to the production environment.
Disable: Saves a rule but does not publish it to the production environment.

Saves a rule but does not publish it to the production environment.

Saves and publishes a rule to the production environment.

If a single rule is complex and has multiple IF statements, you can add comments tothem. Then, the rule navigation will be automatically generated on the right of the rule
content to simplify viewing and locating.

©2013-2022 Tencent Cloud. All rights reserved.

Page 20 of 23

Tencent Cloud EdgeOne

variables：

Last updated 2024-08-01 21:32:16

Introduction
The variables of the rule engine allow you to dynamically extract and process data within request. These variables can
not only store static values but also use for specific fields or information in the request, the value of which may change
when processing each request. For example: the http.request.host variable, which can extract thehostname in each HTTP request. This capability enables the rule engine to handle more complex business logic.

Content
Name

Type

Description

http.request.scheme

StringClient request protocol

http.request.zone

StringSite nameexample.com

http.request.zoneid

StringSite IDzone-2c2r77pc3796

http.request.host

StringHostname in the client
request URI

www.example.com

http.request.full_uri

StringFull URI of the client
request (not including#fragment)

htt‐
ps://www.example.org/articles/index?
section=539061&expand=comments

http.request.method

StringClient request HTTP
methodGET

http.request.uri

StringClient request URI pathand query string/articles/index?
section=539061&expand=comments

http.request.uri.path

StringClient request URI path/articles/index

http.request.file_extension

StringFile extension of the client
request filejpg

http.request.filename

StringFilename of the client
request file

bot.txt©2013-2022 Tencent Cloud. All rights reserved.

Examplehttphttps

Page 21 of 23

Tencent Cloud EdgeOne

http.request.uri.query

String

The whole query string ofsection=539061&expand=comments

the client request, notincluding the ?
separator
The header value of the
http.request.headers["key"]

Stringspecified header name"key" in the client request,

https://developer.mozilla.org"key" can be replaced withyour specified name
The parameter value of thespecified parameter namehttp.request.uri.args["key"]

String"key" in the client query
string, "key" can be
replaced with yourvalue

specified namehttp.request.version

String

The version of the HTTP
protocol used in the client
requestClient TCP IP address, for

HTTP/1.0
HTTP/1.1
HTTP/2
HTTP/3http.request.ip

Stringhttp.request.ip.port

StringClient Port

1028

http.request.ip.city

StringCity associated with theclient IP address

San Francisco

example: 1.1.1.1

93.184.216.34

AF: Africa

http.request.ip.continent

StringContinent code associatedwith the client IP address

AS: Asia
EU: Europe
NA: North America
SA: South America
OC: Oceania
AN: Antarctica

2-letter country code in
http.request.ip.country

StringISO 3166-1 Alpha 2 format
associated with the client
IP address

GB, see more in ISO 3166-1 Alpha 2﻿

Use Case©2013-2022 Tencent Cloud. All rights reserved.

Page 22 of 23

Tencent Cloud EdgeOne

1. The custom origin-pull request header carries the information of the country where the client IP address is locatedback to the origin.

2. Custom origin-pull request headers allow the origin server to collect and analyze which domains have been
accelerated by Tencent's EdgeOne.

3. Custom Cross-Origin Request Policy: Allows cross-origin requests from domains specified in the Origin header ofthe request.

©2013-2022 Tencent Cloud. All rights reserved.

Page 23 of 23