Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nginx
GitHub Repository: nginx/nginx.org
Path: blob/main/xml/en/docs/http/ngx_http_geoip_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_geoip_module"
11
link="/en/docs/http/ngx_http_geoip_module.html"
12
lang="en"
13
rev="5">
14
15
<section id="summary">
16
17
<para>
18
The <literal>ngx_http_geoip_module</literal> module (0.8.6+) creates variables
19
with values depending on the client IP address, using the precompiled
20
<link url="http://www.maxmind.com">MaxMind</link> databases.
21
</para>
22
23
<para>
24
When using the databases with IPv6 support (1.3.12, 1.2.7),
25
IPv4 addresses are looked up as IPv4-mapped IPv6 addresses.
26
</para>
27
28
<para>
29
This module is not built by default, it should be enabled with the
30
<literal>--with-http_geoip_module</literal>
31
configuration parameter.
32
<note>
33
This module requires the
34
<link url="http://www.maxmind.com/app/c">MaxMind GeoIP</link> library.
35
</note>
36
</para>
37
38
</section>
39
40
41
<section id="example" name="Example Configuration">
42
43
<para>
44
<example>
45
http {
46
geoip_country GeoIP.dat;
47
geoip_city GeoLiteCity.dat;
48
geoip_proxy 192.168.100.0/24;
49
geoip_proxy 2001:0db8::/32;
50
geoip_proxy_recursive on;
51
...
52
</example>
53
</para>
54
55
</section>
56
57
58
<section id="directives" name="Directives">
59
60
<directive name="geoip_country">
61
<syntax><value>file</value></syntax>
62
<default/>
63
<context>http</context>
64
65
<para>
66
Specifies a database used to determine the country
67
depending on the client IP address.
68
The following variables are available when using this database:
69
<list type="tag">
70
71
<tag-name id="var_geoip_country_code"><var>$geoip_country_code</var></tag-name>
72
<tag-desc>
73
two-letter country code, for example,
74
<literal>RU</literal>”, “<literal>US</literal>”.
75
</tag-desc>
76
77
<tag-name id="var_geoip_country_code3"><var>$geoip_country_code3</var>
78
</tag-name>
79
<tag-desc>
80
three-letter country code, for example,
81
<literal>RUS</literal>”, “<literal>USA</literal>”.
82
</tag-desc>
83
84
<tag-name id="var_geoip_country_name"><var>$geoip_country_name</var></tag-name>
85
<tag-desc>
86
country name, for example,
87
<literal>Russian Federation</literal>”, “<literal>United States</literal>”.
88
</tag-desc>
89
90
</list>
91
</para>
92
93
</directive>
94
95
96
<directive name="geoip_city">
97
<syntax><value>file</value></syntax>
98
<default/>
99
<context>http</context>
100
101
<para>
102
Specifies a database used to determine the country, region, and city
103
depending on the client IP address.
104
The following variables are available when using this database:
105
<list type="tag">
106
107
<tag-name id="var_geoip_area_code"><var>$geoip_area_code</var></tag-name>
108
<tag-desc>telephone area code (US only).
109
<note>
110
This variable may contain outdated information since
111
the corresponding database field is deprecated.
112
</note>
113
</tag-desc>
114
115
<tag-name id="var_geoip_city_continent_code">
116
<var>$geoip_city_continent_code</var></tag-name>
117
<tag-desc>two-letter continent code, for example,
118
<literal>EU</literal>”, “<literal>NA</literal>”.
119
</tag-desc>
120
121
<tag-name id="var_geoip_city_country_code"><var>$geoip_city_country_code</var>
122
</tag-name>
123
<tag-desc>
124
two-letter country code, for example,
125
<literal>RU</literal>”, “<literal>US</literal>”.
126
</tag-desc>
127
128
<tag-name id="var_geoip_city_country_code3"><var>$geoip_city_country_code3</var>
129
</tag-name>
130
<tag-desc>
131
three-letter country code, for example,
132
<literal>RUS</literal>”, “<literal>USA</literal>”.
133
</tag-desc>
134
135
<tag-name id="var_geoip_city_country_name"><var>$geoip_city_country_name</var>
136
</tag-name>
137
<tag-desc>
138
country name, for example,
139
<literal>Russian Federation</literal>”, “<literal>United States</literal>”.
140
</tag-desc>
141
142
<tag-name id="var_geoip_dma_code"><var>$geoip_dma_code</var></tag-name>
143
<tag-desc>
144
DMA region code in US (also known as “metro code”), according to the
145
<link url="https://developers.google.com/adwords/api/docs/appendix/cities-DMAregions">geotargeting</link>
146
in Google AdWords API.
147
</tag-desc>
148
149
<tag-name id="var_geoip_latitude"><var>$geoip_latitude</var></tag-name>
150
<tag-desc>latitude.</tag-desc>
151
152
<tag-name id="var_geoip_longitude"><var>$geoip_longitude</var></tag-name>
153
<tag-desc>longitude.</tag-desc>
154
155
<tag-name id="var_geoip_region"><var>$geoip_region</var></tag-name>
156
<tag-desc>
157
two-symbol country region code (region, territory, state, province, federal land
158
and the like), for example,
159
<literal>48</literal>”, “<literal>DC</literal>”.
160
</tag-desc>
161
162
<tag-name id="var_geoip_region_name"><var>$geoip_region_name</var></tag-name>
163
<tag-desc>
164
country region name (region, territory, state, province, federal land
165
and the like), for example,
166
<literal>Moscow City</literal>”, “<literal>District of Columbia</literal>”.
167
</tag-desc>
168
169
<tag-name id="var_geoip_city"><var>$geoip_city</var></tag-name>
170
<tag-desc>
171
city name, for example,
172
<literal>Moscow</literal>”, “<literal>Washington</literal>”.
173
</tag-desc>
174
175
<tag-name id="var_geoip_postal_code"><var>$geoip_postal_code</var></tag-name>
176
<tag-desc>
177
postal code.
178
</tag-desc>
179
180
</list>
181
</para>
182
183
</directive>
184
185
186
<directive name="geoip_org">
187
<syntax><value>file</value></syntax>
188
<default/>
189
<context>http</context>
190
<appeared-in>1.0.3</appeared-in>
191
192
<para>
193
Specifies a database used to determine the organization
194
depending on the client IP address.
195
The following variable is available when using this database:
196
<list type="tag">
197
198
<tag-name id="var_geoip_org"><var>$geoip_org</var></tag-name>
199
<tag-desc>
200
organization name, for example, “The University of Melbourne”.
201
</tag-desc>
202
203
</list>
204
</para>
205
206
</directive>
207
208
209
<directive name="geoip_proxy">
210
<syntax><value>address</value> | <value>CIDR</value></syntax>
211
<default/>
212
<context>http</context>
213
<appeared-in>1.3.0</appeared-in>
214
<appeared-in>1.2.1</appeared-in>
215
216
<para>
217
Defines trusted addresses.
218
When a request comes from a trusted address,
219
an address from the <header>X-Forwarded-For</header> request
220
header field will be used instead.
221
</para>
222
223
</directive>
224
225
226
<directive name="geoip_proxy_recursive">
227
<syntax><literal>on</literal> | <literal>off</literal></syntax>
228
<default>off</default>
229
<context>http</context>
230
<appeared-in>1.3.0</appeared-in>
231
<appeared-in>1.2.1</appeared-in>
232
233
<para>
234
If recursive search is disabled then instead of the original client
235
address that matches one of the trusted addresses, the last
236
address sent in <header>X-Forwarded-For</header> will be used.
237
If recursive search is enabled then instead of the original client
238
address that matches one of the trusted addresses, the last
239
non-trusted address sent in <header>X-Forwarded-For</header> will be used.
240
</para>
241
242
</directive>
243
244
</section>
245
246
</module>
247
248