Configure URL transformation to rewrite and proxy requests

The following section describes the procedure to use NetScaler URL transformation to rewrite and proxy requests.

The rewrite or proxy function in Apache is used to transmit the requests to a host from a different domain. The request is changed to appear as though it is coming from the same host. One of the practical applications of this feature is when you have content being pulled from different locations, and JavaScripts are used. The browser might not allow it to prevent cross-site scripting attacks. You can use the NetScaler appliance to emulate the rewrite or proxy function in Apache.

Prerequisites

To use the URL transformation to rewrite and proxy requests, make sure the following prerequisites are met.

  • The rewrite and content switching features must be enabled on the NetScaler appliance.
  • NetScaler feature release version 9.0 and later.

You can follow the subsequent steps to use the NetScaler URL transformation to rewrite and proxy requests.

Perform the following by using the CLI

  1. Define a content switching virtual server, which routes the incoming request to the IP of www.external.com. For more information on configuring a content switching virtual server, see Content Switching.

  2. Configure the URL transformation.

    • Create transformation profile and action.

      • add transform profile proxy_rewrite
      • add transform action rewrite1 proxy_rewrite 10
      • set transform action rewrite1 -priority 10 -reqUrlFrom "http://www.company.com/key/(.*)" -reqUrlInto "http://www.external.com/$1" -resUrlFrom "http://www.external.com/(.*)" -resUrlInto http://www.example.com/key/$1
    • Create and bind transformation policy.

      • add transform policy rewrite_pol "HTTP.REQ.URL.PATH.GET(1).EQ(\"key\") && http.REQ.HOSTNAME.EQ(\"www.example.com\")" proxy_rewrite
      • bind transform global rewrite_pol 100

Note

The preceding procedure takes the incoming request from www.example.com that is identified by /key/directory, and rewrites them to host www.external.com, by removing the /key/ directory. For example, RewriteRule http://www.example.com/key/(.*)http://www.external.com/$1 [P,L].

Configure URL transformation to rewrite and proxy requests