Forum Discussion
stucky101_88485
Nimbostratus
Aug 30, 2012Sanity check on iRule please
Gurus
We are about to host a bunch of apps on oracle Glassfish. Thing is it GF distinguishes its apps by uri.
People want to be able to type:
store.domain.com
and get there. Of course this gets them to whatever app was deployed under the context root of "/" which isn't the one we're looking for.
The real app is here:
store.domain.com/myecomerceapp
I figured a class would do nicely here to map the "store" hostheader to the "myecomerceapp" uri.
I created a data group list called "host_to_uri" with the following entry :
store. := /myecomerce
Then I created the following iRule :
Redirect uri based on hostheader if necessary.
when HTTP_REQUEST {
Check if our uri is /
if { [HTTP::uri] equals "/" } {
Iterate our hostheader over the redirects class to see if we have a mapping.
set host [class match [HTTP::host] starts_with host_to_uri]
if { $host ne "" } {
We found a key/value pair so let's set the uri to the vale.
set new_uri [class match -value [HTTP::host] starts_with host_to_uri]
if { $new_uri ne "" } {
Do the deed !
HTTP::redirect https://[HTTP::host]$new_uri
}
}
}
}
I also have an http version. This seems to work well but I wanted to run this by you guys. Is this sane ?
Any comments are appreciated.
Thx
2 Replies
- Michael_Yates
Nimbostratus
Hi Stucky101,
You could take a shortcut and bypass the class match compare by verifying that the [HTTP::host] value is the URL that your looking for and then inject the application path into the [HTTP::uri] and then append the requested [HTTP::uri].when HTTP_REQUEST { if { [HTTP::host] equals "store.domain.com" } { HTTP::uri "/myecomerceapp[HTTP::uri]" pool myapplicationpool } }
Hope this helps. - stucky101_88485
Nimbostratus
Mike
1. This looks like transparent uri rewriting which I purposely stayed away from.
2. Wouldn't this break if the uri is already correct ?
Say my url is already store.domain.com/myecomerceapp.
This rule would still kick in and rewrite it to "store.domain.com/myecomerceapp/myecomerceapp" right ?
The rule should only apply if hostname starts with "store." AND the uri is "/"
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
