Let’s put up a scenario when you see a need of replacing the content of an HTTP HEADER…
To make this easy we will use an example to show you how to replace a content of “X-Citrix-Via” header from an IP “192.168.114.282” to a Hostname “smali-lab.envokeit.com

So we will basically need a Netscaler rewrite action and a rewrite policy to make this work…
Make sure you enable the rewrite feature on your Netscaler if not done already…

Rewrite Action:

Name: x_citrix_via_replace_act
Operation: replace
Target: HTTP.REQ.HEADER(“X-Citrix-Via”).INSTANCE(0).AFTER_STR(“:”)
Value: ” smali-lab.envokeit.com\r\n”
BypassSafetyCheck : YES

Rewrite policy:

Name: X-Header-Rewrite-Pol
Rule: HTTP.REQ.HEADER(“X-Citrix-Via”).EQ(“192.168.114.282”)
RewriteAction: x_citrix_via_replace_act
UndefAction: Use Global
LogAction: Use Global

Bind the rewrite policy to an AGVIP or LBVIP…

Code snippet: (Netscaler 11.0 and newer…)

enable ns feature REWRITE
add rewrite action x_citrix_via_replace_act replace “HTTP.REQ.HEADER(\”X-Citrix-Via\”)” “\”smali-lab.envokeit.com\””
add rewrite policy X-Header-Rewrite-Pol “HTTP.REQ.HEADER(\”X-Citrix-Via\”).NE(\”smali-lab.envokeit.com\”)” x_citrix_via_replace_act
bind vpn vserver “Your access gateway vip name” -policy X-Header-Rewrite-Pol -priority 100 -type REQUEST