Team ,
I am still very new to iRules and I am trying to get the code syntax for a simple URL redirect and Browser check to work based on my requirement. My VIP name is the following http://abc-lab.def.test.com.
Basically if I hit url http://abc-lab.def.test.com I get redirected successfully to http://host1.test.com:9500/xyz (shown in my browser).
As next step I would like that i still get redirected to http://host1.test.com:9500/xyz url but would like to keep/show in my browser /xyz (ie:http://abc-lab.def.test.com/xyz) or (ie:
Here is a snippet of my current code : when HTTP_REQUEST { check for browser-type switch -glob [HTTP::header value “User-Agent”] { “MSIE 6” - “MSIE 7" - "MSIE 8” { If MSIE, log IP, port & browser-type. Logs are written to /var/log/ltm log local0. “[IP::client_addr]:[TCP::client_port] :[HTTP::header User-Agent] : Matched MSIE.”
If MSIE, redirect to Capri Redirect page
HTTP::redirect "http://[HTTP::host]:2200/Redirect_url"
}
default {
If other browser, log IP, port & browser-type. Logs are written to /var/log/ltm
log local0. "[IP::client_addr]:[TCP::client_port] :[HTTP::header User-Agent] : Matched default pool"
If other browser, forward to default pool
HTTP::redirect "http://host1.test.com:9500/xyz"
}
} }
Any help with this will be greatly appreciated. Remember, I am still new to iRules.
Thanks!
Hi,
The browser display the request he has done in foreground. To achieve your requirement, you need to :
or
-
change the way it works :
when HTTP_REQUEST {
check for browser-type
switch -glob [HTTP::header value "User-Agent"] {
"MSIE 6" -
"MSIE 7" -
"MSIE 8" {
If MSIE, log IP, port & browser-type. Logs are written to /var/log/ltm
log local0. "[IP::client_addr]:[TCP::client_port] :[HTTP::header User-Agent] : Matched MSIE."
If MSIE, redirect to Capri Redirect page
HTTP::redirect "http://[HTTP::host]:2200/Redirect_url"
}
default {
If other browser, log IP, port & browser-type. Logs are written to /var/log/ltm
log local0. "[IP::client_addr]:[TCP::client_port] :[HTTP::header User-Agent] : Matched default pool"
switch -glob [HTTP::path] {
"/" {
If other browser, forward to default pool
HTTP::redirect "/xyz"
}
default {
node host1 9500
}
}
}
}
}
Hi,
The browser display the request he has done in foreground. To achieve your requirement, you need to :
or
-
change the way it works :
when HTTP_REQUEST {
check for browser-type
switch -glob [HTTP::header value "User-Agent"] {
"MSIE 6" -
"MSIE 7" -
"MSIE 8" {
If MSIE, log IP, port & browser-type. Logs are written to /var/log/ltm
log local0. "[IP::client_addr]:[TCP::client_port] :[HTTP::header User-Agent] : Matched MSIE."
If MSIE, redirect to Capri Redirect page
HTTP::redirect "http://[HTTP::host]:2200/Redirect_url"
}
default {
If other browser, log IP, port & browser-type. Logs are written to /var/log/ltm
log local0. "[IP::client_addr]:[TCP::client_port] :[HTTP::header User-Agent] : Matched default pool"
switch -glob [HTTP::path] {
"/" {
If other browser, forward to default pool
HTTP::redirect "/xyz"
}
default {
node host1 9500
}
}
}
}
}
Yann…appreciate fast response based on my example what are the value i should set for node host1 9500
Yann…appreciate fast response based on my example what are the value i should set for node host1 9500
Hi, in that case, your viewable app url remain http://abc-lab.def.test.com. If you redirect the user to http://abc-lab.def.test.com:9500, this is this url that will be viewed in the browser
Hi, in that case, your viewable app url remain http://abc-lab.def.test.com. If you redirect the user to http://abc-lab.def.test.com:9500, this is this url that will be viewed in the browser
So, with your irule, the VIP that has this irule never go to a pool but redirect every request to a different app or vip.
So, with your irule, the VIP that has this irule never go to a pool but redirect every request to a different app or vip.
In my irule, all the traffic goes through this VS
In my irule, all the traffic goes through this VS
Yann..thanks for your suggestion did test it and work correctly now. Last question I now have is how/what to change in order to handle two/three nodes (ie High availability) as for now you suggest to use : default { node host1 9500 which only point to one node. Thanks,
Yann..thanks for your suggestion did test it and work correctly now. Last question I now have is how/what to change in order to handle two/three nodes (ie High availability) as for now you suggest to use : default { node host1 9500 which only point to one node. Thanks
Yann..thanks for your suggestion did test it and work correctly now. Last question I now have is how/what to change in order to handle two/three nodes (ie High availability) as for now you suggest to use : default { node host1 9500 which only point to one node. Thanks
Hi, you change this command by “pool mypool” and you create a pool of nodes.
Hi, you change this command by “pool mypool” and you create a pool of nodes.
Always sounds easy when you know
Really appreciate your VALUABLE feedback Yann. Have a good week end
Always sounds easy when you know
Really appreciate your VALUABLE feedback Yann. Have a good week end