Forum Discussion
minnoce944
Nimbostratus
Jul 30, 2014http rewrite and pool selection based on method
We have a requirement to perform URI rewrites for specific paths and direct that request to the appropriate pool. As an added bonus we also need to inspect the http method used to make sure we are se...
minnoce944
Nimbostratus
Jul 31, 2014I changed else to elseif and http::host to http::header replace Host since i'm on ver 11.4. It compiles fine now. I'll post back after my testing results.
Below is updated version:
first uri check to determine if it matches
method can be get or put, rewrite URI and route to appropriate pool
when HTTP_REQUEST {
if {( [string tolower [HTTP::uri]] eq "/IMSWeb/IMSServlet" ) } {
HTTP::uri "/ReservationService/IMSServlet"
pool pool1.tcp.8780
}
check to determine appropriate method, perform switch statement
if { [string tolower [HTTP::method]] eq "get" } {
method is get, need to rewrite URI and route to appropriate pool
switch -glob [string tolower [HTTP::uri] ] {
"/IMSWeb/rest/services/inventory" {
HTTP::uri "/ReservationService/IMSServlet"
pool pool1.tcp.8780
}
"/IMSWeb/Lookup" {
HTTP::uri "/ReservationService/UI/invLookUp"
pool pool1.tcp.8780
}
}
}
elseif { [string tolower [HTTP::method]] eq "put" } {
method is put, need to rewrite host & URI and route to appropriate pool
switch -glob [string tolower [HTTP::uri] ] {
"/IMSWeb/rest/services/item" {
HTTP::header replace Host "pool2"
HTTP::uri "/iasserver/rest/services/item"
pool pool2.tcp.80
}
"/IMSWeb/rest/services/inventory" {
HTTP::header replace Host "pool2"
HTTP::uri "/iasserver/rest/services/inventory"
pool pool2.tcp.80
}
}
}
}
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