Forum Discussion
Simple redirect irule - keeping VIP name in browser instead of full redirect url
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!
17 Replies
- Yann_Desmarest_
Nacreous
Hi,
The browser display the request he has done in foreground. To achieve your requirement, you need to :
- use iframes so that the main url remain http://abc-lab.def.test.com
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 } } } } }
- dlegran2_264710
Nimbostratus
Yann...appreciate fast response based on my example what are the value i should set for node host1 9500 - Yann_Desmarest_
Nacreous
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 - Yann_Desmarest_
Nacreous
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.
Hi,
The browser display the request he has done in foreground. To achieve your requirement, you need to :
- use iframes so that the main url remain http://abc-lab.def.test.com
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 } } } } }
- dlegran2_264710
Nimbostratus
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
- 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.
- dlegran2_264710
Nimbostratus
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,
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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