such as God Horse Search and Baidu (http://www.baidu.com), when using desktop browser and mobile browser access to the results are not the same. There are two possible ways to do this:
- Reprint Ngix Reverse proxy judgment
- The service side directly judges the UA output different interface, Java and PHP and other background languages provide support framework
Both have made a special page on the mobile side, so that the function of the demolition, the user experience of course greatly improved, but when there is a change in demand, often have to change two places.
With the advent of the mobile Internet era, many Web sites have launched a mobile client based on mobile phones, ipad and other page access, here is how to use the user UA to achieve user access under different terminal:
$http _user_agent is an nginx built-in parameter that allows you to specify what action to trigger when the user UA satisfies a certain type, and here we take the ipad as an example, configure separate access to the mobile and Web side, first edit the Nginx server {} program segment, Add the following information:
Location /{root/data/www/pc;if ($http _user_agent ~ iPad){ root /data/www/mobile; index index.html index.htm; }Reload Nginx, test time, if there is no ipad device, you can use the Firefox browser plug-in User Agent switcher to simulate a variety of devices, interested can check the usage of this plugin
Ngix mobile End and PC side reverse proxy judgment