Replace HTTP Header Content
About
Replace HTTP Header action is generally used to replace an existing HTTP header's contents using RegEx in the request that was made to the vServices during request or response time. Set HTTP Header is an advanced action that can be used to change only desired words in the HTTP request by using Regular Expressions.
How to Add?
To add a Replace HTTP Header action from TR7 ASP web interface, "Traffic Manager > Traffic Manipulation > Actions > Add" steps are followed. At the current page Replace HTTP Header is selected as an Action Type and the following form is shown.
Applicable vServices
- HTTP
- L7 TCP
- Network
Interface
Replace HTTP Header Content Adding Form
- Action Name
Name for the action is entered.
- Action Type
Replace HTTP Header is selected.
- Execution Level
Action is triggered when the request arrives to the vService.
Action is triggered when the response from the Backend Service arrives to the vService.
- Header to Replace
The name of the header to be edited during the Execution Level is entered.
- Regex to Match
The regular expression to be matched with the header content is written.
- Match Type
Selected when Regex to Match is desired to be matched/searched in the entire header content.
Selected when Regex to Match is desired to be searched/matched against each value seperated by comma.
- Replacement Content
New HTTP Header content Regex is written in accordance to the Regex to Match.
- Conditions
Condition(s) that will trigger the action is/are selected. For detailed information about conditions, click here.
- Form Buttons
- Example Usage
In this example, the Host header content www.tr7.com is replaced with docs.tr7.com.tr in an incoming request to the vService by using the Replace HTTP Header Content. The process is described in detail.
- Execution Level
On Request is selected. (Since Host HTTP Header Content will be changed, On Request is selected.)
- Header to Replace
Host HTTP Header is entered.
- Regex to Match
Assuming that on request time, inside the "Host" header content, "www.tr7.com" is written. Here, the Regex to change the "www" value and to add ".tr" after "com" value is written. (www\.(.*)\.com)
- Match Type
Replace Whole Header is selected.
- Replacement Content
The new HTTP Header Content Regex is written in accordance to the Regex to Match. In the new Regex, "www" value is replaced with "docs" and ".tr" is appended after "com". (docs.\1.com.tr)
- Conditions
Always is selected to trigger Replace HTTP Header Content action at every request incoming to the vService.