码迷,mamicode.com
首页 > Web开发 > 详细

Netscaler URL/Cookie domain Transformation 转换

时间:2018-01-18 23:12:25      阅读:468      评论:0      收藏:0      [点我收藏+]

标签:reg   jin   variable   proc   nsf   对象   操作   des   方便   

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的设计就是在满足稳定性和功能性的前提下尽量让大家的操作简单。

在Rewrite策略下先建立Profile,
技术分享图片

建立Profile后填写需要转换内容的表达式
技术分享图片
转换的对象可以是Request、Responde和Cookie Domain,对于前两者可以是URI也可以是完整的URL。
技术分享图片

然后建立 URL Transformation Policy
技术分享图片
技术分享图片
将此策略绑定到需要的VIP上
技术分享图片
技术分享图片
观察效果:
转换前
技术分享图片
转换后。因为我的服务器上没有/111这个路径,所以看到报错证明转换生效。
技术分享图片

官方文档

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.

Instructions
To change the destination hostname of an HTTP GET request using the URL Transformation feature of a NetScaler appliance, complete the following procedure:

Run the following command from the command line interface of the appliance to create a URL Transformation profile:

add transform profile prof_url_change

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.

来源: <http://support.citrix.com/article/CTX128091>;

Netscaler URL/Cookie domain Transformation 转换

标签:reg   jin   variable   proc   nsf   对象   操作   des   方便   

原文地址:http://blog.51cto.com/caojin/2062640

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!