Forum Discussion
sundogbrew
Altocumulus
Oct 16, 2013Getting 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...
Kevin_Stewart
Employee
Oct 16, 2013Can I assume that if there's nothing after the port number then the newuri variable is empty? If so, then a quick check and replace function should do the trick:
if { not ( $newuri starts_with "/" ) } { set newuri "/${newuri}" }
So it might look something like this:
when HTTP_REQUEST {
set newuri [findstr [HTTP::uri] "/" 5]
if { not ( $newuri starts_with "/" ) } { set newuri "/${newuri}" }
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"
}
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects