Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nginx
GitHub Repository: nginx/nginx.org
Path: blob/main/xml/en/docs/http/ngx_http_browser_module.xml
1 views
1
<?xml version="1.0"?>
2
3
<!--
4
Copyright (C) Igor Sysoev
5
Copyright (C) Nginx, Inc.
6
-->
7
8
<!DOCTYPE module SYSTEM "../../../../dtd/module.dtd">
9
10
<module name="Module ngx_http_browser_module"
11
link="/en/docs/http/ngx_http_browser_module.html"
12
lang="en"
13
rev="2">
14
15
<section id="summary">
16
17
<para>
18
The <literal>ngx_http_browser_module</literal> module creates variables
19
whose values depend on the value of the <header>User-Agent</header>
20
request header field:
21
<list type="tag">
22
23
<tag-name id="var_modern_browser"><var>$modern_browser</var></tag-name>
24
<tag-desc>
25
equals the value set by the <link id="modern_browser_value"/> directive,
26
if a browser was identified as modern;
27
</tag-desc>
28
29
<tag-name id="var_ancient_browser"><var>$ancient_browser</var></tag-name>
30
<tag-desc>
31
equals the value set by the <link id="ancient_browser_value"/> directive,
32
if a browser was identified as ancient;
33
</tag-desc>
34
35
<tag-name id="var_msie"><var>$msie</var></tag-name>
36
<tag-desc>
37
equals “1” if a browser was identified as MSIE of any version.
38
</tag-desc>
39
40
</list>
41
</para>
42
43
</section>
44
45
46
<section id="example" name="Example Configuration">
47
48
<para>
49
Choosing an index file:
50
<example>
51
modern_browser_value "modern.";
52
53
modern_browser msie 5.5;
54
modern_browser gecko 1.0.0;
55
modern_browser opera 9.0;
56
modern_browser safari 413;
57
modern_browser konqueror 3.0;
58
59
index index.${modern_browser}html index.html;
60
</example>
61
</para>
62
63
<para>
64
Redirection for old browsers:
65
<example>
66
modern_browser msie 5.0;
67
modern_browser gecko 0.9.1;
68
modern_browser opera 8.0;
69
modern_browser safari 413;
70
modern_browser konqueror 3.0;
71
72
modern_browser unlisted;
73
74
ancient_browser Links Lynx netscape4;
75
76
if ($ancient_browser) {
77
rewrite ^ /ancient.html;
78
}
79
</example>
80
</para>
81
82
</section>
83
84
85
<section id="directives" name="Directives">
86
87
<directive name="ancient_browser">
88
<syntax><value>string</value> ...</syntax>
89
<default/>
90
<context>http</context>
91
<context>server</context>
92
<context>location</context>
93
94
<para>
95
If any of the specified substrings is found in the <header>User-Agent</header>
96
request header field, the browser will be considered ancient.
97
The special string “<literal>netscape4</literal>” corresponds to the
98
regular expression “<literal>^Mozilla/[1-4]</literal>”.
99
</para>
100
101
</directive>
102
103
104
<directive name="ancient_browser_value">
105
<syntax><value>string</value></syntax>
106
<default>1</default>
107
<context>http</context>
108
<context>server</context>
109
<context>location</context>
110
111
<para>
112
Sets a value for the <var>$ancient_browser</var> variables.
113
</para>
114
115
</directive>
116
117
118
<directive name="modern_browser">
119
<syntax><value>browser</value> <value>version</value></syntax>
120
<syntax><literal>unlisted</literal></syntax>
121
<default/>
122
<context>http</context>
123
<context>server</context>
124
<context>location</context>
125
126
<para>
127
Specifies a version starting from which a browser is considered modern.
128
A browser can be any one of the following: <literal>msie</literal>,
129
<literal>gecko</literal> (browsers based on Mozilla),
130
<literal>opera</literal>, <literal>safari</literal>,
131
or <literal>konqueror</literal>.
132
</para>
133
134
<para>
135
Versions can be specified in the following formats: X, X.X, X.X.X, or X.X.X.X.
136
The maximum values for each of the format are
137
4000, 4000.99, 4000.99.99, and 4000.99.99.99, respectively.
138
</para>
139
140
<para>
141
The special value <literal>unlisted</literal> specifies to consider
142
a browser as modern if it was not listed by the
143
<literal>modern_browser</literal> and <link id="ancient_browser"/>
144
directives.
145
Otherwise such a browser is considered ancient.
146
If a request does not provide the <header>User-Agent</header> field
147
in the header, the browser is treated as not being listed.
148
</para>
149
150
</directive>
151
152
153
<directive name="modern_browser_value">
154
<syntax><value>string</value></syntax>
155
<default>1</default>
156
<context>http</context>
157
<context>server</context>
158
<context>location</context>
159
160
<para>
161
Sets a value for the <var>$modern_browser</var> variables.
162
</para>
163
164
</directive>
165
166
</section>
167
168
</module>
169
170