What I am trying to do is setup NGINX to detect specific country codes. I have this working properly right now adding in lines such as
if ($geoip_country_code = IE) { rewrite ^(.*) http://link.com/for/Ireland;
This is in my actual site config file not my nginx.conf file.
What I would like to also do is add in a mobile check to this, such as if it's Ireland AND mobile its will go to a second link. Is this even possible to do at this level? Or am I stuck just detecting the country at the server level then have to deal with mobile in a more standard way such as when the page is loading and using a mobile detection script. I know I can do it this way, but I would love to be able to add in the detection into the same catch in my NGINX config.
Thanks for all the help and information.
Take a look at http://detectmobilebrowsers.com. It has code snippet for nginx.
Recently I did such nginx configuration, works fine.
You are far better off using code redirects than nginx configuration due to the incredible difference in user-agents for mobile. In particular, the cost of invoking a serie of if statements on nginx is non-trivial.
This website has a non-exhaustive list of mobile user-agents, old and not-so-old. You'll quickly see that the list is actually quite gianormous, to say the least. Let's focus on just iPhones, iPods and iPads for now. They're pretty easy to differentiate:
Mozilla/5.0 (device type; cpu type; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3
So, this one will not pose problem. However, the string is very similar to other things, including Safari's desktop user-agent... And this is for the easiest of phones. Android has no such simplicity. Take, for instance, the HTC Desire:
Mozilla/5.0 (Linux; U; Android 2.1-update1; de-de; HTC Desire 1.19.161.5 Build/ERE27) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17
The identifier for the OS changed to the third field, which means that you now need a minimum of two regular expression engine calls to match iPhones and some android. I'm saying some, because... Well, let's go to the Motorola Droid:
MOT-V9mm/00.62 UP.Browser/6.2.3.4.c.1.123 (GUI) MMP/2.0
...Waaat?
Conclusion: you'll need a database of user-agents if you care about false positives. If you don't, just do broad checks on nginx using regular expressions on the user-agent, searching for the keywords iPad, iPhone, iPod, Android, Windows Phone. That will flag about 80-85% of all mobile users. If you want to match everyone, you'll need to use a DB of user-agents due to manufacturers re-writing their useragents.
Related
I use LWP::UserAgent to access the web site. The site offers almost the same info in auto-selected layouts for pc (default?) and mobile. Some informations are easier to get in non default layout.
Which User-Agent most generic strings are recommended to identify web client as mobile or pc device?
LWP::UserAgent : $ua->agent('…');
P.S. So far for tests I use full string of randomly selected mobile device. It works but I would like to set proper "style-guide" - set and forget for LONG. I would like to avoid requirement for fixes every few years.
In my specific case Mozilla/5.0 (Mobile) delivers wanted results.
IMHO it is worth to try in other cases.
$ua->agent('Mozilla/5.0 (Mobile)');
I have tried it based on suggestion in
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent
Firefox UA string
[…] The UA string of Firefox itself is broken down into four components:
Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion
Mozilla/5.0 is the general token that says the browser is Mozilla compatible, and is common to almost every browser today.
platform describes the native platform the browser is running on (e.g. Windows, Mac, Linux or Android), and whether or not it's a mobile phone. Firefox OS phones simply say "Mobile"; the web is the platform.
[…]
I'm trying to detect the devices that open my newsletter parsing the user-agent that request my 1x1 tracking image. The problem is that Gmail save all of the images in his storage and the user agent is always "Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko Firefox/11.0 (via ggpht.com GoogleImageProxy)", this if the opener is from the gmail app and when is from the desktop interface.
Now the question is, there's a way to tell Google avoiding to save the image in the newsletter? Maybe there's a custom header in the mail?
Or maybe there are other solutions for detecting the tipology of the devices that open newsletter from gmail official interface?
Thanks to all.
Yuri
The only solution I'm aware of is the one provided by ContactMonkey, but it's a proprietary system so I'm not sure of how it works. They have a free plan so you can test out their software and see if it fits your needs.
I got a Samsung Smart TV UE40D8000 (Apparently from 2011 series ?) and an iOS device.
I'd like to make them both exchange information (most likely small chunks of text), via a dedicated app on both sides;
Now, it turns out the best way would be to use the Convergence API : I've built a basic TV App that looks an awefull lot like the sample code they give, and an iOS App for UPnP discovery and sending POST requests onto the TV. UPnP discovery works great.
But on the actual device, I can't seem to be able to manage to connect : the requests to /ws/app/{appID}/connect fail (with an actual appID of course) as if there would be no server.
Is the Convergence API available for my TV ? (there does not seem to have a compatibility list anywhere) Is there a way to upgrade to a 2012 platform if it is indeed a 2011 one ?
Can we test that API on a simulator ? My simulator runs under Windows 7 in a VM on my Mac (there is not Mac version of their dev tools...)
Is there really anything I can do to have a more precise diagnostic ? like logs from the appilcation running on the TV ?
Thanks
This Convergence page sounds like existence of MultiScreenService UPnP service equals the capability of Convergence API calls. So if you say "UPnP discovery works great" (given that you do an ST-limited M-SEARCH per example, not an unrestricted UPnP discovery), it should mean that your particular TV supports Convergence. Have you tried querying the TV simply with telnet? Are you sure about the port number on which the TV listens? Here the doc claims that it should be 80 for the TV and 8008 for the simulator, but i for one am very interested in the UPnP description.xml served by the TV for MultiScreenService. You could even discover some UPnP functions for diagnostic there...
Disclaimer: i have no experience in Convergence, only UPnP in general and unfortunately Samsung in general too. The fact that Samsung pushes such half-baked proprietary mockup reminds me of my short bloody disgusting career as Bada developer. Only Sony can sustain pushing proprietary mockups with dignity :)
Your year model is 2011 and you can't upgrade to 2012.
2012 models uses API v3.5 and 2011 models uses API v2.5
So this what you try to do won't work at your device as Convergence API is in API v3.5.
Check this one
http://www.samsungdforum.com/Guide/View/Developer_Documentation/Samsung_SmartTV_Developer_Documentation_2.5/API_Reference/JavaScript_APIs/Interactive_API
It gives you possibility to communicate between devices, so maybe it will fit your needs.
Finishing answering my own question:
like #Dobiatowski mentions, I'm screwed for Convergence API and 2012 platform
The Interactive API's documentation is not clear, and virtually non-fonctionnal despite 3 days of my best effort. Half of the sentence in the documentation don't actually make sense.
Still did not manage to make the interactivity simulator to work, Looks like it's not possible on Win7
Basic answer is : not possible
I'm trying to connect to a vnc server from iPhone using NoVNC.
I have some issues with "mouse" which behaves very irrationally.
Has anyone experienced the same behaviour ?
(will post code in a few)
I am the noVNC maintainer. Supporting mobile devices with touchscreens has been on my list for a while. I just filed a issue to track this feature.
Supporting touchscreen interfaces is quite different from normal mouse support. Also, noVNC will probably need to have viewport support for usability and performance reasons on mobile devices.
I do have an iPhone, and I do want to get this functionality working, but I'm not sure when I'll be able to get around to it. Help is always welcome. :-)
I'm having trouble with an old pre-mobile website which uses PHP, MySQL, cookies and HTML forms to log users in, and then track their session (it's a calendar app and messageboard). When my iPhone is attached to my wifi network at home, all is well, but when I switch to 3G the cookies no longer function and the session is dropped.
I read another thread:
Web site exhibits JavaScript error on iPad / iPhone under 3G but not under WiFi
in which the poster was experiencing a javascript issue on 3G but not on WiFi, and the suggestion was that the cellular carrier (O2 in his case, Orange UK in my case) itself was messing with the HTTP data going across 3G, but not WiFi. The fix was to use more javascript to prevent inlining of includes.
Does anyone think that my cookie and session problems are possibly caused by a similar issue, and if not can anyone think of an alternative explanation and ideally a fix?
Aha - I found out what the problem was. The cookie control on the site in question was actually being run by an installation of phpBB, which uses IP binding as a security measure. This checks off the IP addresses of successive requests within a session and drops it if they don't match. Must be the case that over wifi I have an unchanging IP, while Orange UK must bounce around several IP addresses when I run over 3G. Solved the problem by turning down the IP binding in phpBB (you can ask it to compare the whole address or just the first 2 or 3 bytes instead).
I'm guessing your 3G provider is proxying your HTTP somehow. It's common for some (in my opinion, crappier) ISPs to do this. That would be an explanation of why it is behaving differently to the same browser on another connection.
Lots of people will access your site over a proxy such as Squid. You need to fix this so it works or you might inadvertently block access to some people.
My guess is that your code may just be setting cookies in a particular way which is forgiven by browsers but not supported by that particular proxy. I'd start troubleshooting by specifying the domain, expiry in different ways (with dot at start of domain and without, with quotes around domain/path and without) and turning on or off Cookie2 features or HTTP-only features.
Is there an HTTP header viewer for the iPhone browser? If not try tethering it and use something like LiveHTTPheaders in Firefox (keep in mind that if your network can detect tethering it could in theory turn on/off its proxy based on whether you tether).
You'd probably have to post your code or an HTTP transcript (just the headers) for people to diagnose further.