- 06 Nov 2024
- 2 Minutes to read
- Print
- PDF
Processing Stages
- Updated on 06 Nov 2024
- 2 Minutes to read
- Print
- PDF
Overview
The Processing Stage rules are applied during a specific stage of the overall transaction (On Client Request, On Origin Request, On Client Response.)
Supported Processing Stage rules:
- Client Request Access - Sets the conditions for rejecting or redirecting client requests based on header information. For example, to block referrer URLs or user agents.
- Origin Selection - This rule is applied to the client request. It influences the origin selection. Use it to direct certain client requests (for example, requests from a specified user agent) to an alternate origin.
- Modify Origin Request - Modifies the request to the origin by manipulating the URI or headers in the request received from the client.
- Modify Client Response - Modifies the response to the client by overriding the status code or manipulating the headers of the response from the origin.
Note that the inheritance logic for Processing Stage Rules considers them as a single entity. Therefore, if any Processing Stage rule is configured at the path level, it overrides all processing stage rules configured at the host level.
For example, if the host configuration includes an On Client Request and an On Client Response rule, and the path configuration includes an On Origin Request rule, then only the On Origin Request rule is applied to the path.
SVTA Component: MI.ProcessingStages
When you configure any of the Processing Stage rules and save the configuration version, the MI.ProcessingStages component is added to the JSON configuration.
In this example, all four Processing Stage rules are configured. Note that the client-request section sets three distinct rules: two Client Request Access rules and one Origin Selection rule.
For further explanation, refer to these Knowledge Base articles: Origin Selection, Modify Origin Request, Modify Client Response, Client Request Access.
{
"generic-metadata-type": "MI.ProcessingStages",
"generic-metadata-value": {
"client-response": [
{
"stage-metadata": [
{
"response-transform": {
"headers": {
"add": [
{
"value": "qwilt",
"name": "served-by",
"value-is-expression": false
}
]
}
}
}
]
}
],
"client-request": [
{
"stage-metadata": [
{
"response-transform": {
"synthetic": {
"response-status": "403"
}
}
}
],
"match": {
"expression": "req.h.MySecret != 'm1y2e3f4b5m6m7y9'"
}
},
{
"stage-metadata": [
{
"generic-metadata": [
{
"generic-metadata-type": "MI.SourceMetadataExtended",
"generic-metadata-value": {
"sources": [
{
"protocol": "https/1.1",
"endpoints": [
"example.origin2.com"
]
}
]
}
}
]
}
],
"match": {
"expression": "req.h.user-agent ~= 'Mozilla'"
}
},
{
"stage-metadata": [
{
"response-transform": {
"synthetic": {
"response-status": "301",
"headers": [
{
"name": "location",
"value": "'https://the-other-server.com' . req.uri.path",
"value-is-expression": true
}
]
}
}
}
],
"match": {
"expression": "req.h.referer ~= 'https://example.com'. req.uri.path"
}
}
],
"origin-request": [
{
"stage-metadata": [
{
"request-transform": {
"headers": {
"add": [
{
"value": "qwilt",
"name": "x-cdn",
"value-is-expression": false
}
]
}
}
}
]
}
]
}
}