I've updated the directive to support IE9 on Windows Phone.
Added the bot detection.
The following is a reference to an open (but not open source) solution provided by my company to detect mobile devices (or any kind of HTTP client in fact) through NGINX.
I figured that companies looking for a professionally supported solution in this space may want to know about it.
Would you please give an usage example?