Create request and response rules
Rewrite the path an application requests from the origin, and remove a header from the response, with two rules created in Azion Console.
Rules Engine is a feature of Applications that applies the business rules of your application without code. The reverse-proxy architecture of an application runs each rule in one of two phases. The Request Phase carries the data a client sends to an origin server. The Response Phase carries the data the origin sends to the client. You create a rule for either phase from Azion Console.
Some Rules Engine variables and behaviors are available only while Application Accelerator is on. Rewrite Request, used in the first task, is one of them. Filter Response Header, used in the second, is not.
Prerequisites
- An application. To create one, refer to Applications quickstart.
- Access to Azion Console. Refer to Access Azion Console.
- Application Accelerator on the application, for the request rule only. The module can generate usage-related costs. For the rates, refer to Pricing.
Turn on Application Accelerator
The module is off by default, and a rule uses Rewrite Request only while the module is on. To turn it on:
Access Azion Console > Applications > your application.
On the Main Settings tab, in the Modules section, turn on Application Accelerator.
The application runs with Application Accelerator, and a rule can use Rewrite Request.
Rewrite a request path
A rule in the Request Phase runs before the request to the origin servers is completed. With Rewrite Request, a client receives content from a URI that does not match its path at the origin.
The goal of this task is to deliver the contents of /content/page.html when a client requests https://www.domain.com/page. To create the rule that rewrites the request:
Access Azion Console > Applications > your application, then go to the Rules Engine tab.
Enter a name that identifies the rule, and a description if you need one.
In the Criteria section, select the ${uri} variable.
Set the comparison operator to is equal to.
Enter /page as the argument. The criteria identifies the URL of the request by the URI trailing slash /.
Enter ${uri}content/page.html. The argument concatenates the ${uri} variable, whose value is /, with the path of the page.
A request to https://www.domain.com/page returns the contents of /content/page.html. The client does not enter the entire address in the browser. A new rule takes a few minutes to propagate.
Remove a header from the response
A rule in the Response Phase runs before the response is delivered to the client. With Filter Response Header, the rule removes an HTTP header from that response. The behavior does not require Application Accelerator.
A response carries the Server header, which holds information about the server that produced it. Removing that header keeps clients from receiving information about the infrastructure of your application. The removal reduces what an attacker can read about that infrastructure.
To filter the Server header from the response:
Access Azion Console > Applications > your application, then go to the Rules Engine tab.
Enter a name that identifies the rule, and a description if you need one.
In the Criteria section, select the ${uri} variable.
Set the comparison operator to starts with.
Enter / as the argument. The criteria runs the rule for the entire application.
Enter Server. The argument removes every instance of the Server header from all responses.
Responses from the application no longer carry the Server header. A new rule takes a few minutes to propagate.