Forum Discussion

Chuck_13207's avatar
Chuck_13207
Icon for Nimbostratus rankNimbostratus
Aug 10, 2012

Problem figuring out how to rewite what is sent to pool

I have a link that I want to be minus a directory when it is sent to the pool.

 

 

The issue is this:

 

 

The user clicks on a link like this:

 

https://fqdn/tr1/W.aspx?L=Nb8PMkM

 

 

I need to remove the dir /tr1/ when it gets sent back to the pool

 

./W.aspx?L=Nb8PMkM

 

 

I am sorry, i am new to TCL scripting and iRules so I need some help

 

 

Thanks

 

5 Replies

  • I was thinking about something like this, but it is for the simplest case and is not tested:

    
    when HTTP_REQUEST {
        set pathvar [HTTP::path]
        string map {"/tr1" ""} $pathvar
        HTTP::path $pathvar 
    }
    

    There is a lot to consider though...

    -Would /tr1 show up anywhere else in a URL that is valid?

    -Should the user see the new path in their address bar or not?

    -Do we need to do this for every case or should there be some logic?

    Hope that helps...
  • Sorry, I have been out on vacation for the weekend. Thanks for responding.

     

     

    We have 2 servers on the backend that can generate an URL. By default it looks like this; https://server.ip/W.aspx?9293430

     

     

    Both generate the same format as well you can put anything between the https:// and the /W.aspx?. I wanted to have it generate something like this; https://FQDN/tr1/W.aspx?23kd93 and https://FQDN/tr2/W.aspx?234f3234

     

     

    That way I can tell which URLs are coming from which server. On the front end, it looks like the above, and depending on the dir (/tr1/ or /tr2/) I will send it to that pool, strip off the dir and just give it the ./W.aspx? to that server to retrieve the image and pass it back to the client.

     

     

    I hope this makes sense.

     

     

    Thanks
  • OK, how about this:

     
    when HTTP_REQUEST {
        set pathvar [HTTP::path]
        if { [HTTP::path] contains "/tr1" }{
            string map {"/tr1" ""} $pathvar
            HTTP::path $pathvar 
            pool pool_tr1
        }
        elseif { [HTTP::path] contains "/tr2" }{
            string map {"/tr2" ""} $pathvar
            HTTP::path $pathvar 
            pool pool_tr2
        }
    }
    
  • Can I send you the irule we currently have so you can see what is currently being used and maybe you can see how this needs to work?
  • Hi Chuck,

     

     

    You could post an anonymized copy of the iRule to get feedback.

     

     

    Aaron