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 |
|
|
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 |
|
|
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.
cccandbbbare 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 is 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/aaaThe requested path is matched if
/sys/(.*)/(.*)/aaais specified as the forwarding condition.
Then
Rewrite
-
Domain Name: Specifies the domain name to which requests are rewritten. If you leave this parameter empty, the original domain name is retained.
-
Path: Specifies the path to which requests are rewritten. If you leave this parameter empty, the original path is retained. For more information about path enhancement, see the Configure paths for rewrites and redirects section.
-
Search: Specifies the query string to which requests are rewritten. If you leave this parameter empty, the original query string is retained.
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 is 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/aaaThe requested path is matched if
/sys/(.*)/(.*)/aaais specified as the forwarding condition.
Then
Redirect
-
Protocol: Specifies the protocol for redirection. Valid values: HTTP and HTTPS. If you leave this parameter empty, the default value HTTP is used.
-
Domain Name: Specifies the domain name for redirection. If you leave this parameter empty, the original domain name is retained.
-
Port: Specifies the port for redirection. If you leave this parameter empty, the default value is 80 for HTTP listeners and 443 for HTTPS listeners.
-
Path: Specifies the path for redirection. If you leave this parameter empty, the original path is retained. For more information about path enhancement, see the Configure paths for rewrites and redirects section.
-
Search: Specifies the query string for redirection. If you leave this parameter empty, the original query string is retained.
-
Status Code:
301
-