FAQ

Page Discussion History

Difference between revisions of "HttpBrowserModule"

(Directives)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
<span style="color:red">WARNING: this article is obsoleted. Please refer to http://nginx.org/en/docs/ for the latest official documentation.</span>
 +
 
= Synopsis =
 
= Synopsis =
 
This module creates variables, the values of which depend on the request header "User-agent":
 
This module creates variables, the values of which depend on the request header "User-agent":
Line 41: Line 43:
  
 
== ancient_browser ==
 
== ancient_browser ==
 
+
<include wikitext nopre src="http://wiki.nginx.org/nginx.org/http/ngx_http_browser_module/ancient_browser.txt" />
{{Directive|name=ancient_browser|args=line [ line... ]|default=none|context=http, server, location|variables=no}}
+
  
 
Directive assigns the substrings, during presence of which in the line "User-agent", browser are considered as '''old'''.<BR>
 
Directive assigns the substrings, during presence of which in the line "User-agent", browser are considered as '''old'''.<BR>
 
Special line "netscape4" corresponds to regular expression "^Mozilla/[1-4] ".
 
Special line "netscape4" corresponds to regular expression "^Mozilla/[1-4] ".
 
  
 
== ancient_browser_value ==
 
== ancient_browser_value ==
 
+
<include wikitext nopre src="http://wiki.nginx.org/nginx.org/http/ngx_http_browser_module/ancient_browser_value.txt" />
{{Directive|name=ancient_browser_value|args=value|default=1|context=http, server, location|variables=no}}
+
  
 
Directive assigns value for the variables $ancient_browser.
 
Directive assigns value for the variables $ancient_browser.
 
  
 
== modern_browser ==
 
== modern_browser ==
 
+
<include wikitext nopre src="http://wiki.nginx.org/nginx.org/http/ngx_http_browser_module/modern_browser.txt" />
{{Directive|name=modern_browser|args=browser version {{!}} unlisted|default=none|context=http, server, location|variables=no}}
+
  
 
Directive assigns which version of the browser is to be considered as '''modern'''.<BR>
 
Directive assigns which version of the browser is to be considered as '''modern'''.<BR>
Line 66: Line 63:
 
Special value "unlisted" indicates to consider modern browser, not described by the modern_browser and ancient_browser directives. <BR>
 
Special value "unlisted" indicates to consider modern browser, not described by the modern_browser and ancient_browser directives. <BR>
 
If the headers do not contain "User-agent", the browser is considered ancient (unless "modern_browser unlisted" is specified).
 
If the headers do not contain "User-agent", the browser is considered ancient (unless "modern_browser unlisted" is specified).
 
  
 
== modern_browser_value ==
 
== modern_browser_value ==
 
+
<include wikitext nopre src="http://wiki.nginx.org/nginx.org/http/ngx_http_browser_module/modern_browser_value.txt" />
{{Directive|name=modern_browser_value|args=value|default=1|context=http, server, location|variables=no}}
+
  
 
Directive assigns value for the variables $modern_browser.
 
Directive assigns value for the variables $modern_browser.
Line 81: Line 76:
  
 
= References =
 
= References =
[http://sysoev.ru/nginx/docs/http/ngx_http_browser_module.html Original Documentation] new since 26.09.2006 version 0.4.3
+
[http://nginx.org/en/docs/http/ngx_http_browser_module.html Original Documentation]

Revision as of 21:33, 22 August 2013

WARNING: this article is obsoleted. Please refer to http://nginx.org/en/docs/ for the latest official documentation.

Contents

Synopsis

This module creates variables, the values of which depend on the request 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 - is equal to the value, assigned by directive ancient_browser_value, if browser is identified as an old browser;
  • $msie - is equal 1, if browser is identified as MSIE with any version;

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

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;
}

Directives

ancient_browser

Syntax: ancient_browser string ...
Default:
Context: http
server
location
Reference:ancient_browser


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 string
Default: 1
Context: http
server
location
Reference:ancient_browser_value


Directive assigns value for the variables $ancient_browser.

modern_browser

Syntax: modern_browser browser version
modern_browser unlisted
Default:
Context: http
server
location
Reference:modern_browser


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.
If the headers do not contain "User-agent", the browser is considered ancient (unless "modern_browser unlisted" is specified).

modern_browser_value

Syntax: modern_browser_value string
Default: 1
Context: http
server
location
Reference:modern_browser_value


Directive assigns value for the variables $modern_browser.

Examples

Note The use of ancient_browser in the link provided below is broken it should use:

ancient_browser "MSIE 4.0" "MSIE 5.0" "MSIE 5.5" "MSIE 6.0";

Example of use: support only recent versions of Chrome, Firefox, Internet Explorer, Safari, Mobile Safari and Palm Pre

References

Original Documentation