The rewrite feature is a very useful feature when Citrix NetScaler is used to publish HTTP/SSL or TCP information. This feature can be used for request or response traffic. Rewrite is very useful for hiding/removing configurations, appending the default page, custom HTTP errors, hiding HTTP headers, and so on.
The rewrite feature requires a rule and an action to perform the required tasks. The rule is used to identify whether the rule needs to be applied. The configured action will perform the actual action—what we like to rewrite. It's possible to bind multiple rewrite policies on every bind point. Based on the priority, we can define what needs to be applied first if the rule matches the request.
The bind point could be at a global level or defined for a specific Citrix NetScaler load balancing or content switching virtual server.
The rewrite feature also has some default rewrites installed, and these can't be deleted.
The policies from the rewrite feature are followed according to these steps:
While adding the rewrite policy to the bind point, there is the GoTo expression, which can be filled in. The default is the END function. The options available are as follows:
The preceding diagram describes the flowchart of the rewrite feature.
Citrix NetScaler has a lot of actions available for performing actions. The most commonly used action will be explained as follows:
Rewrite action type |
Expression to choose target location |
Argument |
---|---|---|
|
The HTTP header that we like to insert. |
The expression that describes the contents of the HTTP header that needs to be inserted. |
|
The expression that contains information on where the action needs to be evaluated. |
The text that needs to be added before the target location. |
|
The expression that contains information on where the action needs to be evaluated. |
The text that needs to be added after the target location. |
|
The expression that contains information on where the action needs to be evaluated. |
The text that needs to be replaced by the target location expression. |
|
A string expression that describes what needs to be deleted. | |
|
The name of the HTTP header that we want to delete. | |
|
The name of the HTTP header that we don't want visible on the receiver side. | |
|
The matching expression that needs to be sent back. This will be an HTTP response. | |
|
The expression that contains information on where the action needs to be evaluated. |
All of the text that needs to be replaced by the target location expression. |
|
A string expression that describes what needs to be deleted. | |
|
The expression that contains information on where the action needs to be evaluated. |
The text that needs to be added after the target location. |
|
The expression that contains information on where the action needs to be evaluated. |
The text that needs to be added before the target location. |
Go to AppExpert | Rewrite | Actions and click on Add. Fill in the correct information based on the following explanation:
Depending on the type, there will be an extra field that needs to be filled in.
Now the action is done, and we need to create a policy.
Go to AppExpert | Rewrite | Policies and click on Add. Fill in the correct information based on the explanation given here:
Insert
: The rewrite action that we created earlier. All rewrite actions will be visible.NOREWRITE
: The request or response will not be rewritten.RESET
: The connection will be aborted at the TCP level.DROP
: The message will be dropped.After these steps, we can bind the policy to the global level or a specific Citrix NetScaler virtual server.