Citrix Systems Network Router 9.2 User Manual

Page of 302
 Appendix  B        Summary Examples of Advanced Expressions and Policies
239
The following table shows examples of policy configurations and bindings for 
commonly-used functions.
Check if the first 1024 bytes of the 
body of a request starts with the 
string “some text”.
http.req.body(1024).contains("some 
text")
Examples of Advanced Expressions and Policies
Purpose
Example
Use the Rewrite feature to 
replace occurrences of 
http:// with https:// in the 
body of an HTTP 
response.
add rewrite action httpRewriteAction 
replace_all http.res.body(50000) "\"https://
\"" -pattern http://
add rewrite policy demo_rep34312 
"http.res.body(50000).contains(\"http://\")" 
httpRewriteAction
Replace all occurrences of 
“abcd” with “1234”.
add rewrite action abcdTo1234Action 
replace_all "http.req.body(1000)" "\"1234\"" 
-pattern abcd
add rewrite policy abcdTo1234Policy 
"http.req.body(1000).contains(\"abcd\")" 
abcdTo1234Action
bind rewrite global abcdTo1234Policy 100 END 
-type REQ_OVERRIDE
Downgrade the HTTP 
version to 1.0 to prevent 
the server from chunking 
HTTP responses.
add rewrite action downgradeTo1.0Action 
replace http.req.version.minor "\"0\""
add rewrite policy downgradeTo1.0Policy 
"http.req.version.minor.eq(1)" 
downgradeTo1.0Action 
bind lb vserver myLBVserver -policyName 
downgradeTo1.0Policy -priority 100 
-gotoPriorityExpression NEXT -type REQUEST
Remove references to the 
HTTP or HTTPS protocol 
in all responses, so that if 
the user's connection is 
HTTP, the link is opened 
by using HTTP, and if the 
user's connection is 
HTTPS, the link is opened 
by using HTTPS. 
add rewrite action remove_http_https 
replace_all 
"http.res.body(1000000).set_text_mode(ignore
case)" "\"//\"" -pattern "re~https?://
|HTTPS?://~"
add rewrite policy remove_http_https true 
remove_http_https 
bind lb vserver test_vsvr -policyName 
remove_http_https -priority 20 
-gotoPriorityExpression NEXT -type RESPONSE
Examples of Advanced Expressions
Expression Type
Sample Expressions