Citrix

How to Use URL Transformation to Rewrite and Proxy Requests

  • CTX124732
  • Created onMar 26, 2014
  • Updated onJun 19, 2014
Article Topic Networking

Objective

This article describes how to use URL transformation to rewrite and proxy requests.

Background

The rewrite/proxy function in Apache can be used to funnel requests to a host from a different domain, and change it to appear as if it is coming from the same host. One of the practical application of this feature is when you have content being pulled from different locations, and javascripts are being used, the browser might not allow it to prevent cross-site scripting attacks. It is possible to use the NetScaler appliance to emulate the rewrite/proxy function in Apache.

Requirements

For this function to work properly, the rewrite and content switching functions must be enabled on the NetScaler appliance. The appliance must be installed with NetScaler software release 9.0 or later to take advantage of the URL transform feature.

Instructions

To implement the same function as the Apache rewrite rule use the following procedure.

RewriteRule ^http://www.example.com/key/(.*) http://www.external.com/$1 [P,L]

This procedure takes incoming request for www.example.com, identified by the /key/ directory, and rewrites them to host www.external.com, removing the /key/ directory.

  1. Define a content switching virtual server which routes the incoming request to the IP of www.external.com.

  2. Configure the URL transformation as follows:

    • 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.company.com\")" proxy_rewrite
      bind transform global rewrite_pol 100

Applicable Products

Automatic translation

Important: This article was translated by an automatic translation system (also referred to as Machine Translation, or MT) and has not been translated or reviewed by people. Citrix offers a machine translated version of this article to allow for greater access to the support content. However, automatic translation is not always perfect and may contain errors of vocabulary, syntax or grammar. Citrix is not responsible for inconsistencies, errors or damage incurred as a result of the use of MT articles from our customers.Thank you.
Click here to see the English version of this article.
Languages
Was this helpful?
Thank you for your feedback

Share your comments or find out more about this topic

Citrix Forums