Forum Discussion
stucky101_88485
Aug 30, 2012Nimbostratus
Sanity 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
- Michael_YatesNimbostratusHi Stucky101,
when HTTP_REQUEST { if { [HTTP::host] equals "store.domain.com" } { HTTP::uri "/myecomerceapp[HTTP::uri]" pool myapplicationpool } }
- stucky101_88485NimbostratusMike
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