Nginx browser Module

Source: Internet
Author: User
The author Ayou: http: sudone.com can use this module to treat requests from various browsers differently. Generally, different browsers can be implemented using if tags and regular expressions in nginx. Compared with regular expressions, this module provides better performance and makes the configuration file clearer, however, the function is weak. Standard provided by this module

Author Ayou: http ://SuDone.com/

This module can be used to differentiate requests from various browsers. The difference between the if tag and Regular ExpressionExpression implementation, Regular ExpressionThis module provides better performance and makes the configuration file clearer, but the function is weak.

This module provides a lot of labels and syntaxes, mainly including modern_browser and. NcIent_browser. The two labels are literally "new browser" and "old browser". Therefore, the browser module uses the User-Agent header sent from the client, divide requests into "new browser requests" and "old browser requests ". So here is a question: can this module divide only two types of requests? The answer is yes. That is to say, if you want to apply three Homepages for ie6, ie7, and ie8 respectively, this module still cannot do it. In this case, you can only use regular expressions to divide the two Homepages for ie6 and ie7, yes.

Modern_browser

Modern_browser specifies the new browser type, but the browser parameters of the modern_browser label are predefined and cannot be left empty. The browser parameters are only msie, gecko (Mozilla-bas EdBrowsers) opera, safari, and konqueror. In addition, the browser parameter that can be written is unlisted, indicating all browsers. Modern_browser also has a browser version parameter, such as msie 6.0.

Configuration example:

Modern_browser msie 5.5;
Modern_browser gecko 1.0.0;
Modern_browser opera 9.0;
Modern_browser safari 413;
Modern_browser konqueror 3.0;

Entent_browser

Entent_browser specifies the old browser type. Unlike modern_browser, entent_browser can customize parameters, which refer to strings contained in the User_Agent header. The ancient_browser parameter is case sensitive.

Configuration example:

Ancient_browser BlackBerry;
Entent_browser UCWEB;
Ancient_browser UCWEB BlackBerry;

After defining these two labels, you can use the $ modern_browser or $ entent_browser variable to determine whether the labels belong to the new browser or the old one.

If ($ modern_browser)
{
...
}

If ($ clientent_browser)
{
...
}

Note: If the User-Agent is null, it will be regarded as a new browser.

The browser module also has two labels: modern_browser_value and entent_browser_value. The two labels can specify the values of $ modern_browser and $ entent_browser when the conditions are met. In the preceding example, both $ modern_browser and $ entent_browser TrUe or fa LsE.

Modern_browser_value modern .;
Modern_browser msie 5.5;
Ind ExIndex. $ {modern_browser} html index.html;

Write index.modern.html and index.html to get index.modern.html from the page views of msie 5.5.

Due to the weak functionality of this module, it is still troublesome to use this module to handle things.

The following configuration is used to determine the mobile browser:

Modern_browser unlisted;

Entent_browser GoBrowser;
Entent_browser MIDP;
Entent_browser WAP;
Entent_browser UP. Browser;
Ancient_browser Smartphone;
Entent_browser Obigo;
Ancient_browser Mobile;
Entent_browser AU. Browser;
Entent_browser wxd. Mms;
Entent_browser WxdB. Browser;
Entent_browser CLDC;
Entent_browser UP. Link;
Entent_browser KM. Browser;
Entent_browser UCWEB;
Entent_browser SEMC-Browser;
Entent_browser Mini;
Ancient_browser Symbian;
Entent_browser Palm;
Ancient_browser Nokia;
Ancient_browser Panasonic;
Entent_browser MOT -;
Entent_browser SonyEricsson;
Ancient_browser NEC -;
Entent_browser Al CatEl;
Entent_browser Ericsson;
Ancient_browser BENQ;
Ancient_browser BenQ;
Entent_browser Amoisonic;
Entent_browser Amoi;
Entent_browser Capitel;
Entent_browser PHILIPS;
Ancient_browser SAMSUNG;
Ancient_browser Lenovo;
Entent_browser Mitsu;
Entent_browser Motorola;
Entent_browser SHARP;
Entent_browser WAPPER;
Ancient_browser LG -;
Ancient_browser LG /;
Entent_browser EG900;
Entent_browser CECT;
Entent_browser Compal;
Entent_browser kejian;
Entent_browser Bird;
Entent_browser BIRD;
Entent_browser G900/V1.0;
Ancient_browser Arima;
Entent_browser CTL;
Entent_browser TDG;
Entent_browser Daxian;
Entent_browser DBTEL;
Ancient_browser Eastcom;
Ancient_browser EASTCOM;
Ancient_browser PANTECH;
Entent_browser Dopod;
Entent_browser Haier;
Entent_browser HAIER;
Entent_browser KONKA;
Entent_browser KEJIAN;
Ancient_browser LENOVO;
Ancient_browser Soutec;
Ancient_browser SOUTEC;
Entent_browser SAGEM;
Entent_browser SEC;
Entent_browser SED -;
Entent_browser EMOL;
Entent_browser INNO55;
Entent_browser ZTE;
Ancient_browser iPhone;
Entent_browser Andro Id;
Ancient_browser Windows CE;
Entent_browser DX;
Entent_browser TELSON;
Entent_browser TCL;
Ancient_browser oppo;
Entent_browser ChangHong;
Ancient_browser MALATA;
Entent_browser KTOUCH;
Entent_browser TIANYU;
Entent_browser TOUCH;
Ancient_browser MAUI;
Ancient_browser j2s;
Ancient_browser BlackBerry;
Entent_browser yulong;
Entent_browser coolpad;

If ($ clientent_browser)
{
Proxy_pass http://m.sudone.com;
}

In this configuration, the mobile browser is configured in entent_browser, and the Computer Browser is modern_browser.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.