Global Accelerator (GA) listeners support domain name-based and path-based forwarding rules. This topic describes how to configure domain name-based and path-based forwarding conditions. This topic also describes how to configure paths for rewrites and redirects.
Configure domain names in forwarding conditions
You can specify a specific domain name, a wildcard domain name, or a regular expression as the forwarding condition in a domain name-based forwarding rule. For more information about how to add a forwarding rule, see Add a forwarding rule.
Match type | Description |
Exact match and wildcard match |
|
Regular expression match (case-insensitive) |
|
Configure paths in forwarding conditions
You can specify a specific path, a wildcard path, or a regular expression as the match condition in a path-based forwarding rule. For more information about how to add a forwarding rule, see Add a forwarding rule.
Match type | Description |
Exact match and wildcard match |
|
Regular expression match (case-sensitive) |
|
Configure paths for rewrites and redirects
If you specify a regular expression as the match condition in a rewrite or redirect rule, the regular expression is overwritten by the path to which requests are redirected or rewritten. For more information about how to add a forwarding rule, see Add a forwarding rule.
For more information about how to configure regular expressions in path-based forwarding conditions, see the Configure paths in forwarding conditions section of this topic.
Precautions
The number of capture groups, defined by parentheses (
( )
), must be the same as the number of variables, defined by dollar signs ($
), in the path to which requests are rewritten or redirected.You can use up to three variables (
${1}
,${2}
, and${3}
) to form the path that overwrites the original path. The variables cannot be replaced with other characters.
Procedure
Path matching: The client sends a request and matches the regular expression in a path-based forwarding rule.
Extraction and replacement: The content extracted from the capture groups, defined by parentheses (
( )
), are written to${1}
,${2}
, and${3}
. The content is used in the path to which requests are rewritten or redirected.Concatenation: The variables
${1}
,${2}
, and${3}
are replaced with actual values. The values are concatenated to form the actual path.
No.
Step
Example
1
Configure the forwarding condition and forwarding action in the forwarding rule.
Path in forwarding condition:
/sys/(.*)/(.*)/aaa
Path to which requests are rewritten or redirected:
/${1}/${2}
2
A client request matches the path in a forwarding rule.
Requested path:
/sys/ccc/bbb/aaa
Matched path:
/sys/(.*)/(.*)/aaa
3
The system extracts values from the regular expression and replaces the variables with the values.
ccc
andbbb
are extracted from(.*)
in the regular expression and replace the variables ${1} and ${2} in the path to which requests are rewritten or redirected.${1}
is replaced byccc
.${2}
is replaced bybbb
.
4
The values are concatenated to form the actual path.
The path received by the backend server is
/ccc/bbb
.Examples
You can create forwarding rules in the GA console based on the preceding usage notes and procedure The following examples show how to configure forwarding rules.
Example 1: Configure a rule whose actions are Rewrite and Forward
Parameter
Description
If (Matching All Conditions)
Path: Regular Expression Match(Case-sensitive)
Match conditions
The requested path matches the specified regular expression.
Requirements
The regular expression can contain letters, digits, and the following special characters:
. - _ / \ = ? ~ ^ * $ : ( ) [ ] + | " ' @
Examples
Requested path:
/sys/ccc/bbb/aaa
The requested path is matched if
/sys/(.*)/(.*)/aaa
is specified as the forwarding condition.
Then
Rewrite
Domain Name:
${host}
Path:
/${1}/${2}
Search:
${query}
Forward
Select a virtual endpoint group from the drop-down list.
Example 2: Configure a forwarding rule whose action is Redirect
Parameter
Description
If (Matching All Conditions)
Path: Regular Expression Matching (Case-sensitive)
Match conditions
The requested path matches the specified regular expression.
Requirements
The regular expression can contain letters, digits, and the following special characters:
. - _ / \ = ? ~ ^ * $ : ( ) [ ] + | " ' @
Examples
Requested path:
/sys/ccc/bbb/aaa
The requested path is matched if
/sys/(.*)/(.*)/aaa
is specified as the forwarding condition.
Then
Redirect
Protocol:
$protocol
Hosts:
${host}
Port:
${port}
Path:
/${1}/${2}
Search:
${query}
Status Code:
301