Netscaler URL/Cookie domain Transformation 转换
咱们常常会碰到不少URL或cookie改写的需求,在netscaler10.1版本之前只能经过比较复杂的标准rewrite策略来作,不但费时并且还容易出错。后续的版本特地把比较这类操做频繁但需求又不复杂的操做从rewrite中摘出来,造成 transformation模块。能够作转换的对象包括request方向和response方向的URL(注意是hostname+URI均可以改,不仅是路径),Cookie的domain,复合正则表达式能够用的很是灵活(若是感受正则不太会写,能够参考《Netscaler数据索引String Map与Pattern Set的 》来方便枚举不算太多的参数)总之Netscaler的设计就是在知足稳定性和功能性的前提下尽可能让你们的操做简单。html
在Rewrite策略下先创建Profile,正则表达式
创建Profile后填写须要转换内容的表达式
转换的对象能够是Request、Responde和Cookie Domain,对于前二者能够是URI也能够是完整的URL。服务器
而后创建 URL Transformation Policy
将此策略绑定到须要的VIP上
观察效果:
转换前
转换后。由于个人服务器上没有/111这个路径,因此看到报错证实转换生效。cookie
官方文档app
How to Change Destination Hostname of HTTP GET Request Using URL Transformation Feature
CTX128091 Created onMay 07, 2014 Updated onMay 07, 2014
1 found this helpful
Article Topic : Configuration
See Applicable Products
Objective
This article provides information on how to change the Destination Hostname of an HTTP GET Request using the URL Transformation feature.dom
Instructions
To change the destination hostname of an HTTP GET request using the URL Transformation feature of a NetScaler appliance, complete the following procedure:ide
Run the following command from the command line interface of the appliance to create a URL Transformation profile:this
add transform profile prof_url_changeurl
Run the following command to create a URL ransformation action:设计
add transform action act_url_change prof_url_change 100
Run the following command to configure a URL Transformation action:
set transform action act_url_change -priority 100 -reqUrlFrom "http://one.example.co.uk/(.)/(.)/" -reqUrlInto "http://$1.one.example.local/$2/" -resUrlFrom "http://(.*).one.example.local/(.*)" -resUrlInto “http://one.example.co.uk/$1/$2”
In the preceding command, the reqUrlFrom section is regex-compliant. Therefore, you can create variables, such as $1, based on word groups. You can use $1 to $5 variables for the reqUrlInto parameter.
Note: The $1 variable refers to the first (.), the $2 variable refers to the second (.), and / is a delimiter.
Run the following command to configure the URL Transformation policy:
add transform policy pol_url_change "HTTP.REQ.URL.PATH.GET(1).EQ(\"firstpath\") && HTTP.REQ.HOSTNAME.EQ(\"one.example.co.uk\")" prof_url_change
Run the following command to bind the policy globally to the appliance:
bind transform global pol_url_change 10
After configuring the appliance with the preceding configuration, if you try to access the http://one.example.co.uk/firstpath/secondpath/test.html URL, the appliance sends the http://firstpath.one.example.co.uk/secondpath/test.html URL to the backend server.
Note: In this article, URL is transformed using the first element of the path. However, you can extend this to the other elements of the URL.