Alexander_01_13
Oct 31, 2014Nimbostratus
irule for choosing pool and rewriting
Hi experts,
I need to write an irule for the following rewriting task.
http://host.domain.tld/example1/appname >> http://[example1_pool]/appname
http://host.domain.tld/example2/appname >> http://[example2_pool]/appname
http://host.domain.tld/example3/appname >> http://[example3_pool]/appname
So depending on the uri I want to choose the pool and also remove the portion between the first and second slash ("/example1").
The application listens on http://[backend_pool]/appname
The following irule does not do the job yet. Do I have to rewrite the answer also on event HTTP_RESONSE? Do I have to use the "STREAM" command?
Any help is appreciated! Regards, Alexander
when HTTP_REQUEST {
switch -glob -- [string tolower [HTTP::uri]] {
"/example1" {
redirect
HTTP::redirect http://[HTTP::host]/example1/appname
}
"/example1/*" {
HTTP::uri [string map {"/example1" ""} [HTTP::uri]]
pool APPNAME_POOL_example1
}
default {
This final section takes all traffic that has not otherwise
been accounted for
pool wwwserver_pool
}
}
}