09-Jun-2021 09:32
Hi All,
I need help in setting up iRule to redirect to separate URLs for GET and POST request. I have iRule configured for GET request and working but not able to sue for POST request.
GET:
https://www.abc.com/AA/BB ----> https://Node_X:10004/AA/BB
POST:
https://www.abc.com/AA/BB ----> https://Node_P:10008/AA/YY/ZZ
Any help will be greatly appreciated.
Thank you.
09-Jun-2021
12:22
- last edited on
21-Nov-2022
16:18
by
JimmyPackets
It appears, for POST request you want uri rewrite, where first uri path would be same, trimming anything after it and adding some other static URI path but not from the request itself? Also, this doesn't appear to be redirect but sending to pool (or node) on the same LTM? Please note, HTTP POST method doesn't follow a redirect.
If yes for all above, you can try the below code.
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"/aa*"
{
if { [HTTP::method] eq "POST" } {
set first_uri [lindex [split [HTTP::uri] "/"] 1]
set new_uri /$first_uri/YY/ZZ
HTTP::uri $new_uri
pool p_10008
} else {
pool x_10004
}
}
default {
return
}
}
}