Getting a forwarding port from a URI
This is kind of a revisit. I asked this question and got some help a few months back but now there is more needed from the developer (isn't that always the way?)
SO I wrote the below Irule with a lot of help from you guys. The problem I am having now is that "sometimes" the uri is only the port. So www.blablabla.com/1234/ works with the script below, but I can't figure out how to make it work if I remove the second slash. So www.blablabla.com/1234 doesn't work. I need it to be able to work with no second slash as well as a few slashes. In other words I need www.blablabla.com/1234 to work as well as www.blablabla.com/1234/more/crap/after/here. Can anyone see how to make both work?
when HTTP_REQUEST { set newuri [findstr [HTTP::uri] "/" 5] log local0. "Original request is: [HTTP::host][HTTP::uri]" log local0. "New URI is: $newuri" set newport [findstr [HTTP::uri] "/" 1 4] HTTP::uri "$newuri" log local0. "New Port is: $newport" HTTP::header replace Host "[HTTP::host]:$newport"
if { $newport ne "" } { Use the relevant Pool pool mule_pool_$newport } else { log local0. "Newport Variable was empty" } }
As always Thank you very much for your help! Joe