How to Change Destination Hostname of HTTP GET Request Using URL Transformation Feature

How to Change Destination Hostname of HTTP GET Request Using URL Transformation Feature

book

Article ID: CTX128091

calendar_today

Updated On:

Description

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:

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

    add transform profile prof_url_change

  2. Run the following command to create a URL transformation action:

    add transform action act_url_change prof_url_change 100

  3. 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.

  4. 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

  5. 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.

Issue/Introduction

This article contains information about using the Uniform Resource Locator (URL) Transformation feature of a NetScaler appliance to change the destination hostname of an HTTP GET request based on the URL.