Nginx 教程

主要文档

Nginx功能概述 为什么选择Nginx Nginx安装 常见问题(FAQ) 配置符号参考 调试 nginx 优化 Nginx 运行和控制Nginx

核心模块

Nginx事件模块 Nginx主模块

基本模块

Browser模块 Charset模块 Geo模块 HttpAccess模块 HttpAuthBasic模块 HttpAutoindex模块 HttpEmptyGif模块 HttpFcgi模块 HttpGzip模块 HttpHeaders模块 HttpIndex模块 HttpIndex模块. HttpLimit zone HttpLimitReqest模块 HttpLog模块 HttpProxy模块 HttpRewrite模块 HttpSSI模块 HttpUserId http核心模块 map Memcached

其他模块

Addition模块 EmbeddedPerl flv GooglePerftools HttpDav模块 HttpGeoIP HttpGzipStatic HttpImageFilter HttpRealIp HttpSecureLink HttpSSL HttpSubstitution HttpXSLT RandomIndex StubStatus模块

mail模块

MailAuth MailCore MailProxy MailSSL

安装

nginx php-fpm安装配置 nginx在fedora上的安装 nginx在freebsd上的安装 nginx在ubuntu上的安装 nginx在windows上的安装

配置示例和方法

HWLoadbalancerCheckErrors nginx防盗链 负载均衡 完整例子 完整例子2 虚拟主机

Browser模块


摘要

This module creates variables, the values of which depend on the request header "User-agent":

本模块的变量基于请求头(header)中的"User-agent":

  • $modern_browser - is equal to the value, assigned by directive modern_browser_value, if browser is identified as an modern browser;
  • $ancient_browser - 当等于指定给modern_browser_value的浏览器时,这个浏览器被认定为新版的浏览器;
  • $ancient_browser - is equal to the value, assigned by directive ancient_browser_value, if browser is identified as an old browser;
  • $ancient_browser - 当等于指定给ancient_browser_value的浏览器时,这个浏览器被认定为老版的浏览器;
  • $msie - is equal 1, if browser is identified as MSIE with any version;
  • $msie - 当浏览器为MSIE的任何版本时,这个值等于1;

If you don't need this module add --without-http_browser_module parameter to the ./configure call, at compile time.

如果不需要这个模块时,在编译的时候加上 --without-http_browser_module.

Example configuration 例如配置

Selection of the index file:

选择索引文件:

modern_browser_value "modern.";

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;
index index.${modern_browser}html index.html; 

Redirect for the old browsers:

定义老的浏览器:

modern_browser msie 5.0;

modern_browser gecko 0.9.1;
modern_browser opera 8.0;
modern_browser safari 413;
modern_browser konqueror 3.0;

modern_browser unlisted;
ancient_browser Links Lynx Netscape4;

if ($ancient_browser){
  rewrite  ^  /ancient.html;
} 

指令

ancient_browser

syntax:*ancient_browser line [ line... ]*

default:*no*

context:*http, server, location*

Directive assigns the substrings, during presence of which in the line "User-agent", browser are considered as old.
Special line "netscape4" corresponds to regular expression "^Mozilla/[1-4] ".

ancient_browser_value

syntax:*ancient_browser_value line*

default:*ancient_browser_value 1*

context:*http, server, location*

Directive assigns value for the variables $ancient_browser.

定义 $ancient_browser的变量值.

modern_browser

syntax:*modern_browser browser version|unlisted*

default:*no*

context:*http, server, location*

Directive assigns which version of the browser is to be considered as modern.
As browser you can assign the values msie, gecko (Mozilla-based browsers) opera, safari, konqueror.

Of versions it is possible to assign in size X, X.X, X.X.X, or X.X.X.X. maximum values for each of their sizes respectively - 4000, 4000.99, 4000.99.99, and 4000.99.99.99.

Special value "unlisted" indicates to consider modern browser, not described by the modern_browser and ancient_browser directives.
Otherwise the neperechislennyy browser will be considered become obsolete.
If the headers do not contain "User-agent", the browser is considered neperechislennym.

modern_browser_value

syntax:*modern_browser_value line*

default:*modern_browser_value 1*

context:*http, server, location*

Directive assigns value for the variables $modern_browser.

定义$modern_browser的变量值.

References

Original Documentation new since 26.09.2006 version 0.4.3