Appendix B Summary Examples of Advanced Expressions and Policies 239

Examples of Advanced Expressions

Expression Type

Sample Expressions

 

 

Check if the first 1024 bytes of the

http.req.body(1024).contains("some

body of a request starts with the

text")

string “some text”.

 

The following table shows examples of policy configurations and bindings for commonly-used functions.

Examples of Advanced Expressions and Policies

Purpose

Example

 

 

Use the Rewrite feature to

add rewrite action httpRewriteAction

replace occurrences of

replace_all http.res.body(50000) "\"https://

http:// with https:// in the

\"" -pattern http://

body of an HTTP

add rewrite policy demo_rep34312

response.

 

"http.res.body(50000).contains(\"http://\")"

 

httpRewriteAction

Replace all occurrences of

add rewrite action abcdTo1234Action

“abcd” with “1234”.

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

add rewrite action downgradeTo1.0Action

version to 1.0 to prevent

replace http.req.version.minor "\"0\""

the server from chunking

add rewrite policy downgradeTo1.0Policy

HTTP responses.

 

"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

add rewrite action remove_http_https

HTTP or HTTPS protocol

replace_all

in all responses, so that if

"http.res.body(1000000).set_text_mode(ignore

the user's connection is

case)" "\"//\"" -pattern "re~https?://

HTTP, the link is opened

HTTPS?://~"

by using HTTP, and if the

user's connection is

add rewrite policy remove_http_https true

HTTPS, the link is opened

remove_http_https

by using HTTPS.

bind lb vserver test_vsvr -policyName

 

 

remove_http_https -priority 20

 

-gotoPriorityExpression NEXT -type RESPONSE

Page 253
Image 253
Citrix Systems 9.2 manual Examples of Advanced Expressions and Policies, Purpose Example