Forum Discussion
Mobile redirect with forced SSL
Hi guys,
I am faced with dual puzzle for site demending dual function redirect causing some issses.
I need to provide detection process from www.main.com site provide mobile type version/release services.
I establised individual VIP exposed and registered externally with m.main.com. Requests sourcing from mobile devices are detected and redirected to m.version VIP using script I enclosed below. It works well and relatively all devices are detected and rediected properly. All are happy and I still have the job. Problem develops with adding SSL force redirect after mobile deterction takes place. Standard http_https_redirect fails to complete after my first script runs.
Concept is relatively simple. All traffic to standard VIP is redirected to SSL. Same applies to mobile frame devices and they all need to be SSL forced.
Can you please share some light on single or dual step scripts you know work with this requirements?
I appreciate your help .
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::header User-Agent]] {
"*blackberry*" -
"*windows ce*" -
"*palm*" -
"*sonyericsson*" -
"*lg*" -
"*sie*" -
"*up.b*" -
"*up*" -
"*motorola*" -
"*mot-*" -
"*astel;*" -
"*j-phone*" -
"*netfront*" -
"*xiino*" -
"*iphone*" -
"*benq*" -
"*cricket*" -
"*andr*" -
"*htc*" -
"*nokia*" -
"*portalmmm *" -
"*samsung*" -
"*sec*" -
"*vodafone*" -
"*smartphone*" -
"*symbian*" {
HTTP::redirect "]"
return
}
}
if { [string tolower [HTTP::header Accept]] contains "vnd.wap.wml" } {
HTTP::redirect "]"
return
}
if { [HTTP::header exists "MSISDN"] } {
HTTP::redirect "]"
return
}
28 Replies
- hoolio
Cirrostratus
Hi Rafael, - Rafael_Lombardi
Nimbostratus
Hi Aaron, - brad_11480
Nimbostratus
Rafael. Looking at your code, I'm not quite sure the need to establish the pool following the HTTP::redirect when a mobile device is detected (ahh somewhat limited to only an Ipod or Iphone as mobile). The redirect will issue a 302 response, which would essentially end further processing and therefore no resource pool would be touched. - Luke_Drury_7634
Nimbostratus
Hi Guys - nathe
Cirrocumulus
Luke - Luke_Drury_7634
Nimbostratus
Hi Nathan - burakisiksoy_19
Nimbostratus
I got a easy solution if you like. Set the redirect back link on mobile site to different VS then the current VS :)
- Stanislas_Piro2
Cumulonimbus
Hi,
here are two irules you can use:
redirect URL based (user agent are those defined as default in TMG to identify mobile / full user agents)
when HTTP_REQUEST { set clientless_mode 0 Check the requested HTTP Host if {[HTTP::host] equals "site.com"} { Identify User-Agents type switch -glob [string tolower [HTTP::header "User-Agent"]] { "*blazer*" - "*docomo*" - "*windows ce*" - "*symbian os*" - "*sonyericsson*" { set clientless_mode 0 } "*frontpage*" { set clientless_mode 1 } "*mozilla*" - "*opera*" { set clientless_mode 0 } default { set clientless_mode 1 } } if { $clientless_mode} { HTTP::redirect "https://m.site.com[HTTP::uri]" return } } else { pool P_mobile } }
redirect cookie based
when HTTP_REQUEST { set clientless_mode 0 Check the requested Cookie if { ![HTTP::cookie exists "MCookie"] } { Identify User-Agents type switch -glob [string tolower [HTTP::header "User-Agent"]] { "*blazer*" - "*docomo*" - "*windows ce*" - "*symbian os*" - "*sonyericsson*" { set clientless_mode 0 } "*frontpage*" { set clientless_mode 1 } "*mozilla*" - "*opera*" { set clientless_mode 0 } default { set clientless_mode 1 } } if { $clientless_mode} { HTTP::respond 302 noserver Set-Cookie "MCookie="mobile";path=/;secure" Location "https://m.site.com/" return } else { HTTP::respond 302 noserver Set-Cookie "MCookie="full";path=/;secure" Location "https://www.site.com/" } } elseif {[HTTP::cookie value MCookie] equals "mobile"} { pool P_mobile } }
Regards,
Stanislas
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