Netscaler URL/Cookie domain Transformation 轉換

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,
Netscaler URL/Cookie domain Transformation 轉換正則表達式

創建Profile後填寫須要轉換內容的表達式
Netscaler URL/Cookie domain Transformation 轉換
轉換的對象能夠是Request、Responde和Cookie Domain,對於前二者能夠是URI也能夠是完整的URL。
Netscaler URL/Cookie domain Transformation 轉換服務器

而後創建 URL Transformation Policy
Netscaler URL/Cookie domain Transformation 轉換
Netscaler URL/Cookie domain Transformation 轉換
將此策略綁定到須要的VIP上
Netscaler URL/Cookie domain Transformation 轉換
Netscaler URL/Cookie domain Transformation 轉換
觀察效果:
轉換前
Netscaler URL/Cookie domain Transformation 轉換
轉換後。由於個人服務器上沒有/111這個路徑,因此看到報錯證實轉換生效。
Netscaler URL/Cookie domain Transformation 轉換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.

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

相關文章
相關標籤/搜索