CTX124400
NetScaler 8.1,NetScaler 9.0,NetScaler 9.1,NetScaler 9.2,NetScaler VPX 9.1
NetScaler 8.1,NetScaler 9.0,NetScaler 9.1,NetScaler 9.2,NetScaler VPX 9.1
Article
2016-04-15
2015-04-21
This article describes how to use URL Transformation on NetScaler to change the destination path of a GET request based on the User-Agent.

Objective

This article describes how to use URL Transformation??on NetScaler to change the destination path of a GET request based on the User-Agent.

Requirements

Before starting with the URL Transformation configuration it would be beneficial to get an HTTP Header trace to confirm the User-Agents for the client requests. The following two User-Agents are taken from a client using Firefox, version 3.5.8, and Microsoft Internet Explorer, version 7.0. The URL Transformation policy can be configured to match on any expression in the User-Agent header value field.

Firefox UA:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.8) Gecko/20100202 Firefox/3.5.8 GTB6 (.NET CLR 3.5.30729)

Internet Explorer UA:
User-Agent: Mozilla/4.0 (compatible; GoogleToolbar 6.4.1321.1732; Windows XP 5.1; MSIE 7.0.5730.11)


Instructions

All of the following steps should be added through the NetScaler CLI, however, they can also be added through the GUI using the Rewrite section > URL Transformation sub-section.

  1. Create the necessary profiles to contain the actions using the following commands:
    add transform profile ua_url-trans_IE.pro
    add transform profile ua_url-trans_Firefox_pro

  2. Create a URL Transformation action to adjust the URL in its entirety using the following commands. The protocol, hostname, path, and query can all be manually adjusted. The reqUrlFrom section supports Regex and has the ability to create variables ($1) based on word groups. The $1 - $9 variables can be used in the reqUrlInto section.
    add transform action ua_url-trans_Firefox_act ua_url-trans_Firefox_pro 100
    add transform action ua_url-trans_IE_act ua_url-trans_IE.pro 100
    set transform action ua_url-trans_Firefox_act -priority 100 -reqUrlFrom "http://10.54.80.224" -reqUrlInto "http://10.54.80.224/Firefox"
    set transform action ua_url-trans_IE_act -priority 100 -reqUrlFrom "http://10.54.80.224" -reqUrlInto "http://10.54.80.224/IE"

  3. Configure policies to match the destination IP address of the virtual server and the User-Agent header. The regular expression match of the User-Agent header will be case insensitive. The IP address of the VIP is added because of the global binding of URL transformation.
    add transform policy ua_url-trans_Firefox_pol "http.REQ.HOSTNAME.EQ(\"10.54.80.224\") && HTTP.REQ.HEADER(\"User-Agent\").SET_TEXT_MODE(IGNORECASE).REGEX_MATCH(re/Firefox/) " ua_url-trans_Firefox_pro
    add transform policy ua_url-trans_IE_pol "http.REQ.HOSTNAME.EQ(\"10.54.80.224\") && HTTP.REQ.HEADER(\"User-Agent\").SET_TEXT_MODE(IGNORECASE).REGEX_MATCH(re/MSIE/) " ua_url-trans_IE.pro

  4. Globally bind the URL Transformation policies in priority order 20 and 30 using the following commands. When using global bind points you should make the policy expression as specific as possible to prevent matching unintended client requests.
    bind transform global ua_url-trans_Firefox_pol 20
    bind transform global ua_url-trans_IE_pol 30


Additional Resources

The following packet capture screen shot shows a client GET request, using Firefox, to / being adjusted to /Firefox/ for the NetScaler request to the back end server. The second GET request from the client was made using Internet Explorer as the web browser. This resulted in the GET / request being manipulated to GET /IE/ for the back end request.

Environment:

  • Client IP - 10.54.67.214

  • Virtual Server - 10.54.80.224

  • SNIP - 10.54.80.33

  • Server - 10.54.80.24

User-added image


Disclaimer

The above mentioned sample code is provided to you as is with no representations, warranties or conditions of any kind. You may use, modify and distribute it at your own risk. CITRIX DISCLAIMS ALL WARRANTIES WHATSOEVER, EXPRESS, IMPLIED, WRITTEN, ORAL OR STATUTORY, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT. Without limiting the generality of the foregoing, you acknowledge and agree that (a) the sample code may exhibit errors, design flaws or other problems, possibly resulting in loss of data or damage to property; (b) it may not be possible to make the sample code fully functional; and (c) Citrix may, without notice or liability to you, cease to make available the current version and/or any future versions of the sample code. In no event should the code be used to support ultra-hazardous activities, including but not limited to life support or blasting activities. NEITHER CITRIX NOR ITS AFFILIATES OR AGENTS WILL BE LIABLE, UNDER BREACH OF CONTRACT OR ANY OTHER THEORY OF LIABILITY, FOR ANY DAMAGES WHATSOEVER ARISING FROM USE OF THE SAMPLE CODE, INCLUDING WITHOUT LIMITATION DIRECT, SPECIAL, INCIDENTAL, PUNITIVE, CONSEQUENTIAL OR OTHER DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Although the copyright in the code belongs to Citrix, any distribution of the sample code should include only your own standard copyright attribution, and not that of Citrix. You agree to indemnify and defend Citrix against any and all claims arising from your use, modification or distribution of the sample code.

Applicable Products


 

Join the conversation

Citrix Discussions

Open a case

Citrix Support

特别说明


本文来源为Citrix.com所有,翻译后版权归翻译者所有.如需转载请注明出处.

文档版本


.

广告招租


最新留言


.

广告招租


.