Forum Discussion

DannyF_69324's avatar
Icon for Nimbostratus rankNimbostratus
Aug 18, 2011

iRule to display remote content through fake URI

Hey Guys,


I know there is an iRule like this already out there, but I can't seem to find it. Anyway hopefully one of you guys can help me out.


I'm going to be creating several reseller sites for a company each for which will display their own content. All of these sites will then use only one help site which we created so all the resellers can link to. The problem is that if we create the link to our help they will leave the site and will then be redirected to the help site. We want to prevent this by using an iRule that could display the remote site's content when any specific URI is given.



For example:



The help domain would be



The resellers domains would be:




If any of the reseller sites call for we want the help site's content ( to be display under the /help/ URI of any reseller site.



I remember seen something like this before but I can't remember the name of this iRule or what functions were used to create this.



Thanks for any help you can provide.





Danny Fuentes


7 Replies

  • So from the outside you want the to go to the servers actually supporting http://help ? That would be a pool selection based on the hostanme and URI path. Use the "pool" command.



    If you are looking to redirect the user's browser, use the HTTP::redirect or :: response commands.
  • To expand on Ed's description

    One way you could do this is to create pool pointing to the IP address for https://helpsite/help. In my example let's called it pool_helpsite.

    Once that is created you would use the following irule

    when HTTP_REQUEST {
       switch -glob [string to lower [HTTP::uri]
       "/help/"  {  
    HTTP::header replace Location ""
     Pool pool_helpsite
    snat automap

    The snat command basically ensures asynchronise routes to devices in a pool where they are not the gateway.

    I hope this helps

  • Hey Bhattman,

    I tried the iRule you suggested, but I'm getting an error. Seems as if there is an open bracket missing somewhere but I'm not very familiar with TCL so I can't really find the place. The error I'm getting is

     error: line 3: [parse error: extra characters after close-quote] [- "/help/" { HTTP::header replace Location "" Pool pool_helpsite snat automap } ] line 4: [undefined procedure: /help/] ["/help/" { HTTP::header replace Location "" Pool pool_helpsite snat automap }] line 10: [command is not valid in the current scope] [}] 

    I replaced the variables with my own, but for the example posted above I used the same variables in the sample iRule.

    Thanks for the help.
  • Thanks Michael looks like that took care of the problem I had trying to add the iRule. Now the problem that I'm seeing is that the iRule does not seem to be parsing the host header into the request to the IP. The remote site is running with NameVirtualHost and since no host header appears to be passing to the iRule it defaults to the first available site under that IP. Is there a way to fix that?



    Thanks again for the help I may be able to work around this problem if it cant be done.
  • Hi DannyF,

    I modified the HTTP::header portion to look for the Host value. Place the exact IIS Host Head name in that area and you should be good to go.

    when HTTP_REQUEST {
        switch -glob [string tolower [HTTP::uri]] {
        "/help" -
        "/help/" {
            HTTP::header replace Location ""
    HTTP::header replace "Host" ""
            pool pool_helpsite
            snat automap }
  • Nice one Michael. Note that you can remove the -glob flag if you're not using wildcards in the switch statement to save some CPU cycles.