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?
How many virtual servers do you have for these two hostnames? Do you have an http and https VS for both? Which VS(s) do you want to redirect from http to https?
I have a single publically available port 80 VS built for “main” site with addition of VS on same IP address providing final target for SSL termination. Final SSL based target VIP has about 10 servers in the farm. This main set of two VSs (80 and 443 VIPS under one IP address) services about 5 k users on average at any time.
Mobile devices need to be detected and redirected on the first hit on port 80 to www.main.com site and port 80 VS. Once detected, redirect takes place to m.site.com. M site has same two VIPS as well but is new and can be modified accordingly.
When I install redirection script shown, I get redirection working well but SSL redirection with second script fails, regardless where is this applied. I think, It is also safe to say, that m.site needs to respond to port 80 requests as well so it would not be easy to handle SSL requests only on m.site.com VS. M.test.com farm has 4 members in the farm under SSL VIP.
So basically, if I understand this correctly, you want to redirect all traffic from 80 → 443, but with any request coming from a mobile device (as defined by your list of Use-Agents) you want to redirect them to https://m.site.com instead of https://site.com?
If that’s correct, then your iRule is pretty close, and you could simply modify it to handle both cases:
Since all of your previous logical statements have built in return statements anyway, this final if should only be executed if nothing else fired, and will do the global redirect everything to SSL functionality, so you would disable this in the profile or wherever you’re doing it now and let the iRule handle it. That would, I think, solve the problem.
Hi Colin and and thank you for your help. I tried sligtly modified version you attached and noticed it does not work.
Now, it acts strange with firefox vs IE v 8.x. Firefox actually works well. Using FFX I get redirected. Quick test also shows that mobile devices get detected to m-site, but IE 8.x gets to be detected as a mobile devices.
You are right about extend of redirection. It is okay to redirect mobile gear directly to SSL VIP for m-site. It is one process less for any client to get established SSL to m-site.
Buttom line is a requirement that all mobile devices get redirected and be SSL for all sessions right from very first response.
As I attempt to find out what is causing FFX vs IE 8 issue - do you have other suggestions ?
It sounds like this approach will work well for you then, you just need to get a more specific list of User-Agents. One of the User-Agents in your list must be catching IE8 and redirecting it. Perhaps try removing them one by one and testing to see which it is? My guess would be windows ce, but it’s hard to tell.
Agreed that making the matches as unique and detailed as possible is a good thing. The shorter/more ambiguous they are the more chances you have for errors.
I found nice combo set of statements probably capable of taking care of all functionalities but get stuck on syntaxt so further testing is impossible. Can you guys see where I get it wrong. I really appreciate it.
A few of the lines in the switch statement were missing the hyphen. I also set the User-Agent string to lower case so you don’t have to use multiple patterns to handle mixed cases.
Can I ask for little bit more of your opionion on returned requests from mobile site ?
I am facing additional puzzle and dev team finds me pretty quick. Customer now wants to redirect back from mobile vips back to native web site since visitors may want to use full version site.
So when a mobile user goes for full site version vip, script detects the device by user’s agent. (that works well). then
figures out that his screen is capable of displaying more and manually chooses full site button/link on mobile site home page.
Device hits the full site and now gets to be redected and redirected again putting him back on mobile site. Now they fire my ass… (just kidding)
I wander if there is a way to place additional variable or statement into begining of the script used above to practically bypass redirection decision if the client’s device already visited the mobile site.
If I use uri for detecting m site as referer condition I will probably face issues of continuation of other screens since they will not contain referer string any longer.
What you recommend I use for such control and how is this coded ?
How does a mobile user opt out of the mobile site? Is there a specific URL they can access? Can you have the mobile site set a cookie if they opt out? Or could you use an iRule to set a cookie if they opt to use the full site? If so, you could put a check for the cookie first in the full to mobile site redirect rule and just exit the event if it’s there.
We have flexibilty here around building what is considered a requirement. Dev team can certainly help.
As all traffic terminates on main site vip and present irule listed below detects user agent, mobi devices are detected it get redirected to mobile vip. Once they land on mobile vip they get forced into SSL. If user wants to get back to full site based on display capabilities or preference, they select redirect link/button placed on mobile site. Very manual process we can say. We basically can code anything we need on that link or opt button.
Now it is url.
I was wondering if sensing on that string for instance may help sticking the user’s device to the main site vip. Then, how do we stop the process of redirection mechanism which is already part of the script. That would be probably working cool on the initial return of the device from a mobile site but I would this will work with every other request sourcing from that same mobi device? That usefull uri or cookie is not presented any longer with repeated requests and if so condition exists than irule would probably fail to retain that session and redirect again causing the loop effect. I am guessing here mostly. It would probably have to be initial check for parameter being used to prevent redirect of mobi devices onto mobile vip/site. I was wandering if there is a way of allowing the device detection to get redirected to mobil site vip only once for simplicity.
For additional simplicity I would recommend to customer to add simple link/button on main web page to choose manual redirection. Just wondering. Cookie sounds good I guess and it can be added to opt out button too. What would be a method you apply in such case and how do you add it to existing irule to take action before the detection of user-agent begins?
You could add a check for the application set cookie at the top of the iRule using something like this:
when HTTP_REQUEST {
Check if the full site cookie preference has already been set
if {[HTTP::cookie value "full_site_cookie"] eq "some_value"}{
Exit this event in this iRule to avoid a possible redirect to the mobile site
return
}
... rest of the iRule logic to check for mobile user-agents
and redirect them to the mobile site
}
The cookie could also be set by an iRule on the mobile site assuming you can detect when a user has selected a preference within the web app to go back to the full site.
Are you able to change the application to set a cookie when a user opts for the full version of the site? If so, you should be able to use an iRule like the one I posted above.
If the app can’t be changed, are there specific URIs the client accesses when opting for the full version of the site? If so, you could modify the iRule to set the cookie.
Is it possible to do another way without cookies? I mean if we have any url after host send to classic full web site otherwise check for user agent and then if it is mobile send to mobile site?