Binding a Rewrite Policy
After creating a rewrite policy, you must bind it to put it into effect. You can bind your policy to Global if you want to apply it to all traffic that passes through your Citrix ADC, or you can bind your policy to a specific virtual server or bind point to direct only that virtual server or bind point’s incoming traffic to that policy. If an incoming request matches a rewrite policy, the action associated with that policy is carried out.
Rewrite policies for evaluating HTTP requests and responses can be bound to virtual servers of type HTTP or SSL, or they can be bound to the REQ_OVERRIDE, REQ_DEFAULT, RES_OVERRIDE, and RES_DEFAULT bind points. Rewrite policies for TCP rewrite can be bound only to virtual servers of type TCP or SSL_TCP, or to the OTHERTCP_REQ_OVERRIDE, OTHERTCP_REQ_DEFAULT, OTHERTCP_RES_OVERRIDE, and OTHERTCP_RES_DEFAULT bind points.
Note: The term OTHERTCP is used in the context of the Citrix ADC appliance to refer to all TCP or SSL_TCP requests and responses that you want to treat as a raw stream of bytes regardless of the protocols that the TCP packets encapsulate.
When you bind a policy, you assign it a priority. The priority determines the order in which the policies you define are evaluated. You can set the priority to any positive integer.
In the Citrix ADC operating system, policy priorities work in reverse order - the higher the number, the lower the priority. For example, if you have three policies with priorities of 10, 100, and 1000, the policy assigned a priority of 10 is applied first, then the policy assigned a priority of 100, and finally the policy assigned an order of 1000.
Unlike most other features in the Citrix ADC operating system, the rewrite feature continues to evaluate and implement policies after a request matches a policy. However, the effect of a particular action policy on a request or response will often be different depending on whether it is performed before or after another action. Priority is important to get the results you intended.
You can leave yourself plenty of room to add other policies in any order, and still set them to evaluate in the order you want, by setting priorities with intervals of 50 or 100 between each policy when you bind it. If you do this, you can add additional policies at any time without having to reassign the priority of an existing policy.
When binding a rewrite policy, you also have the option of assigning a goto expression (gotoPriorityExpression) to the policy. A goto expression can be any positive integer that matches the priority assigned to a different policy that has a higher priority than the policy that contains the goto expression. If you assign a goto expression to a policy, and a request or response matches the policy, the Citrix ADC will immediately go to the policy whose priority matches the goto expression. It will skip over any policies with priority numbers that are lower than that of the current policy, but higher than the priority number of the goto expression, and not evaluate those policies.
To globally bind a rewrite policy by using the command line interface
At the command prompt, type the following commands to globally bind a rewrite policy and verify the configuration:
bind rewrite global
[ ] [-type ] [-invoke ( )] show rewrite global
Example:
>bind rewrite global policyNew 10 Done > show rewrite global 1) Global bindpoint: RES_DEFAULT Number of bound policies: 1 2) Global bindpoint: REQ_OVERRIDE Number of bound policies: 1 Done
To bind rewrite policy to a specific virtual server by using the command line interface
At the command prompt, type the following commands to bind rewrite policy to a specific virtual server and verify the configuration:
bind lb vserver
@ ( @ [-weight ]) | @ | (-policyName @ [-priority ] [-gotoPriorityExpression ] [-type ( REQUEST | RESPONSE )] [-invoke ( )] ) show lb vserver
Example:
> bind lb vserver lbvip -policyName ns_cmp_msapp -priority 50 Done > > show lb vserver lbvip lbvip (8.7.6.6:80) - HTTP Type: ADDRESS State: DOWN Last state change was at Wed Jul 15 05:54:24 2009 (+226 ms) Time since last state change: 28 days, 01:57:26.350 Effective State: DOWN Client Idle Timeout: 180 sec Down state flush: ENABLED Disable Primary Vserver On Down : DISABLED Port Rewrite : DISABLED No. of Bound Services : 0 (Total) 0 (Active) Configured Method: LEASTCONNECTION Mode: IP Persistence: NONE Vserver IP and Port insertion: OFF Push: DISABLED Push VServer: Push Multi Clients: NO Push Label Rule: none 1) Policy : ns_cmp_msapp Priority:50 2) Policy : cf-pol Priority:1 Inherited Done
To bind a rewrite policy to a bind point by using the configuration utility
- Navigate toAppExpert>Rewrite>Policies.
- In the details pane, select the rewrite policy you want to globally bind, and then clickPolicy Manager.
- In theRewrite Policy Managerdialog box, in theBind Pointsmenu, do one of the following:
- If you want to configure bindings for HTTP rewrite policies, clickHTTP, and then click eitherRequestorResponse, depending on whether you want to configure request-based rewrite policies or response-based rewrite policies.
- If you want to configure bindings for TCP rewrite policies, clickTCP, and then click eitherClientorServer, depending on whether you want to configure client-side TCP rewrite policies or server-side TCP rewrite policies.
- Click the bind point to which you want to bind the rewrite policy. TheRewrite Policy Managerdialog box displays all the rewrite policies that are bound to the selected bind point.
- ClickInsert Policyto insert a new row and display a drop-down list with all available, unbound rewrite policies.
- Click the policy you want to bind to the bind point. The policy is inserted into the list of rewrite policies bound to the bind point.
- In thePrioritycolumn, you can change the priority to any positive integer. For more information about this parameter, see priority in “Parameters for binding a rewrite policy.”
- 如果你想跳过政策和直接to a specific policy in the event that the current policy is matched, change the value in the Goto Expression column to equal the priority of the next policy to be applied.. For more information about this parameter, see gotoPriorityExpression in “Parameters for binding a rewrite policy.”
- To modify a policy, click the policy, and then clickModify Policy.
- To unbind a policy, click the policy, and then clickUnbind Policy.
- To modify an action, in the Action column, click the action you want to modify, and then clickModify Action.
- To modify an invoke label, in theInvokecolumn, click the invoke label you want to modify, and then clickModify Invoke Label.
- To regenerate the priorities of all the policies that are bound to the bind point you are currently configuring, clickRegenerate Priorities. The policies retain their existing priorities relative to the other policies, but the priorities are renumbered in multiples of ten.
- ClickApply Changes.
- ClickClose. A message appears in the status bar, stating that the Policy has been configured successfully.
To bind a rewrite policy to a specific virtual server by using the configuration utility
- Navigate toTraffic Management>Load Balancing>Virtual Servers.
- In the details pane list of virtual servers, select the virtual server to which you want to bind the rewrite policy, and then clickOpen.
- In theConfigure Virtual Server (Load Balancing)dialog box, select thePoliciestab. All policies configured on your Citrix ADC appear on the list.
- Select the check box next to the name of the policy you want to bind to this virtual server.
- ClickOK. A message appears in the status bar, stating that the Policy has been configured successfully.
In this article
- To globally bind a rewrite policy by using the command line interface
- To bind rewrite policy to a specific virtual server by using the command line interface
- To bind a rewrite policy to a bind point by using the configuration utility
- To bind a rewrite policy to a specific virtual server by using the configuration utility