Forum Discussion

kgangi_50732's avatar
kgangi_50732
Icon for Nimbostratus rankNimbostratus
May 22, 2009

Another iRule to rewrite URI

Good morning,

 

 

So an overview of my situation, we have a cell phone app and it goes to some.address.com/uri1/blahblah. We just released a new version and that client goes to somenew.address.com/uri2/blahblah. Client1 traffic was separate for awhile but now we want to send traffic through Client2's uri2 to sort of systematically ween users off of Client1 and on to Client2.

 

 

URL1: some.address.com/uri1/blahblah

 

URI1: uri1

 

 

URL2: somenew.address.com/uri2/blahblah

 

URI2: uri2

 

 

Another thing to notice is that in our QA environment it seems to work ok, though when releasing to production it only worked about half the time. Here is the iRule:

 

 

when HTTP_REQUEST {

 

set DEBUG 1

 

if { $DEBUG } { log local0. "Incoming Request: [HTTP::uri]" }

 

if { [HTTP::uri] starts_with "/uri1/" }{

 

set newUri [string map { /uri1/ /uri2/ } [HTTP::uri]]

 

HTTP::uri $newUri

 

pool pool.perf.uri2

 

if { $DEBUG } { log local0. "new uri $newUri" }

 

if { $DEBUG } { log local0. "Outgoing Request: [HTTP::uri]" }

 

if { $DEBUG } { log local0. "Sending to pool.perf.uri2" }

 

}

 

else {

 

pool pool.perf.uri1

 

if { $DEBUG } {log local0. "Pool Redirect to pool.perf.uri1" }

 

}

 

}

 

 

Nothing should ever hit pool.perf.uri1 but I figured just in case that traffic should probably go there.

 

 

Oh another thing...where there is blahblah is more data. That needs to stay the same...just the uri needs to change. Something that is funny, when looking in the logs, is that I see "Incoming Request: /uri1/blahblah", then "new uri /uri2", but then "Outgoing Request: /uri1/blahblah", and "Sending to pool.perf.uri2".

 

 

I do though see requests coming through on the servers that have the right /uri2/ on them. I just don't know why in the load balancer logs I don't see the new uri when I request HTTP::uri after the writing of the new variable.

 

 

This leads me to believe that maybe this is what is causing me problems in my production environment.

 

 

Any help would be greatly appreciated.

 

 

Thanks

3 Replies

  • The other half went right through to pool.perf.uri1. This really should never happen because we don't send any other traffic but some.address.com/uri1 to this virtual server. So every request should be hitting this iRule.
  • Can you remove "set newUri [string map { /uri1/ /uri2/ } [HTTP::uri]] " and replace "HTTP::uri $newUri " with "HTTP::uri [string map { /uri1/ /uri2/ } [HTTP::uri]] " See if that makes a difference.

     

     

    CB