iRule to hit a specific webserver instance directly
I'm creating an iRule to allow the Ops guys to hit a specific webstore instance directly, by appending a query string to the first page hit, which will then set the proper session cookie to persist on that instance. The request will come in looking like this: http://FQDN/shop/index.jsp categoryId=2255956&server=01_03. We want to strip the query string, and assign a pool member based on the value passed [01_03 = app01, instance03]. Rather than map server numbers to IP addresses, we could just as easily pass the IP and port in the query string too.
I prefer to http://FQDN/shop/index.jsp?categoryId=2255956&server=10.48.162.16:7101 This would avoid having to modify the rule as you add and remove pool members, and it could even be applied to different VIPs. We're looking for something easier to manage. But not sure on what this iRule would look like? Any idea's?
Trying to avoid this, in a cleaner smaller version:
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "_server=01_01" { HTTP::uri [string map -nocase {"&server=01_01" ""} [HTTP::uri]] pool lvs2prdtc3-10.48.172.120.7300 member 10.48.162.16:7101 } "_server=01_02" { HTTP::uri [string map -nocase {"&server=01_02" ""} [HTTP::uri]] pool lvs2prdtc3-10.48.172.120.7300 member 10.48.162.16:7102 } "_server=01_03" { HTTP::uri [string map -nocase {"&server=01_03" ""} [HTTP::uri]] pool lvs2prdtc3-10.48.172.120.7300 member 10.48.162.16:7103 } "_server=02_01" { HTTP::uri [string map -nocase {"&server=02_01" ""} [HTTP::uri]] pool lvs2prdtc3-10.48.172.120.7300 member 10.48.162.17:7101 } "_server=02_02" { HTTP::uri [string map -nocase {"&server=02_02" ""} [HTTP::uri]] pool lvs2prdtc3-10.48.172.120.7300 member 10.48.162.17:7102 } "_server=02_03" { HTTP::uri [string map -nocase {"&server=02_03" ""} [HTTP::uri]] pool lvs2prdtc3-10.48.172.120.7300 member 10.48.162.17:7103 } default { pool lvs2prdtc3-10.48.172.120.7300 } } }
here is exactly what we need:
1) request comes in with IP:port appended as query string: http://trus-lvs2prd.gsipartners.com/shop/index.jsp?categoryId=2255956&server=10.48.162.16:7103
2) we parse the query string and store the IP:port as a variable set target_member = 10.48.162.16:7103
3) pool will always be the same, so set that as a variable too set my_pool = lvs2prdtc3-10.48.172.120.7300
4) we strip the query string, then assign pool and member, with something like this
switch -glob [string tolower [HTTP::uri]] { "*server=$target_member" { HTTP::uri [string map -nocase {"&$target_member" ""} [HTTP::uri]] pool $my_pool member $target_member }
My syntax is wrong, and I don't know if we can use variables in the switch and string map. That's where I need help