Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nginx
GitHub Repository: nginx/nginx.org
Path: blob/main/xml/en/docs/stream/ngx_stream_geoip_module.xml
1 views
1
<?xml version="1.0"?>
2
3
<!--
4
Copyright (C) Nginx, Inc.
5
-->
6
7
<!DOCTYPE module SYSTEM "../../../../dtd/module.dtd">
8
9
<module name="Module ngx_stream_geoip_module"
10
link="/en/docs/stream/ngx_stream_geoip_module.html"
11
lang="en"
12
rev="1">
13
14
<section id="summary">
15
16
<para>
17
The <literal>ngx_stream_geoip_module</literal> module (1.11.3) creates variables
18
with values depending on the client IP address, using the precompiled
19
<link url="http://www.maxmind.com">MaxMind</link> databases.
20
</para>
21
22
<para>
23
When using the databases with IPv6 support,
24
IPv4 addresses are looked up as IPv4-mapped IPv6 addresses.
25
</para>
26
27
<para>
28
This module is not built by default, it should be enabled with the
29
<literal>--with-stream_geoip_module</literal>
30
configuration parameter.
31
<note>
32
This module requires the
33
<link url="http://www.maxmind.com/app/c">MaxMind GeoIP</link> library.
34
</note>
35
</para>
36
37
</section>
38
39
40
<section id="example" name="Example Configuration">
41
42
<para>
43
<example>
44
stream {
45
geoip_country GeoIP.dat;
46
geoip_city GeoLiteCity.dat;
47
48
map $geoip_city_continent_code $nearest_server {
49
default example.com;
50
EU eu.example.com;
51
NA na.example.com;
52
AS as.example.com;
53
}
54
...
55
}
56
</example>
57
</para>
58
59
</section>
60
61
62
<section id="directives" name="Directives">
63
64
<directive name="geoip_country">
65
<syntax><value>file</value></syntax>
66
<default/>
67
<context>stream</context>
68
69
<para>
70
Specifies a database used to determine the country
71
depending on the client IP address.
72
The following variables are available when using this database:
73
<list type="tag">
74
75
<tag-name id="var_geoip_country_code"><var>$geoip_country_code</var></tag-name>
76
<tag-desc>
77
two-letter country code, for example,
78
<literal>RU</literal>”, “<literal>US</literal>”.
79
</tag-desc>
80
81
<tag-name id="var_geoip_country_code3"><var>$geoip_country_code3</var>
82
</tag-name>
83
<tag-desc>
84
three-letter country code, for example,
85
<literal>RUS</literal>”, “<literal>USA</literal>”.
86
</tag-desc>
87
88
<tag-name id="var_geoip_country_name"><var>$geoip_country_name</var></tag-name>
89
<tag-desc>
90
country name, for example,
91
<literal>Russian Federation</literal>”, “<literal>United States</literal>”.
92
</tag-desc>
93
94
</list>
95
</para>
96
97
</directive>
98
99
100
<directive name="geoip_city">
101
<syntax><value>file</value></syntax>
102
<default/>
103
<context>stream</context>
104
105
<para>
106
Specifies a database used to determine the country, region, and city
107
depending on the client IP address.
108
The following variables are available when using this database:
109
<list type="tag">
110
111
<tag-name id="var_geoip_area_code"><var>$geoip_area_code</var></tag-name>
112
<tag-desc>telephone area code (US only).
113
<note>
114
This variable may contain outdated information since
115
the corresponding database field is deprecated.
116
</note>
117
</tag-desc>
118
119
<tag-name id="var_geoip_city_continent_code">
120
<var>$geoip_city_continent_code</var></tag-name>
121
<tag-desc>two-letter continent code, for example,
122
<literal>EU</literal>”, “<literal>NA</literal>”.
123
</tag-desc>
124
125
<tag-name id="var_geoip_city_country_code"><var>$geoip_city_country_code</var>
126
</tag-name>
127
<tag-desc>
128
two-letter country code, for example,
129
<literal>RU</literal>”, “<literal>US</literal>”.
130
</tag-desc>
131
132
<tag-name id="var_geoip_city_country_code3"><var>$geoip_city_country_code3</var>
133
</tag-name>
134
<tag-desc>
135
three-letter country code, for example,
136
<literal>RUS</literal>”, “<literal>USA</literal>”.
137
</tag-desc>
138
139
<tag-name id="var_geoip_city_country_name"><var>$geoip_city_country_name</var>
140
</tag-name>
141
<tag-desc>
142
country name, for example,
143
<literal>Russian Federation</literal>”, “<literal>United States</literal>”.
144
</tag-desc>
145
146
<tag-name id="var_geoip_dma_code"><var>$geoip_dma_code</var></tag-name>
147
<tag-desc>
148
DMA region code in US (also known as “metro code”), according to the
149
<link url="https://developers.google.com/adwords/api/docs/appendix/cities-DMAregions">geotargeting</link>
150
in Google AdWords API.
151
</tag-desc>
152
153
<tag-name id="var_geoip_latitude"><var>$geoip_latitude</var></tag-name>
154
<tag-desc>latitude.</tag-desc>
155
156
<tag-name id="var_geoip_longitude"><var>$geoip_longitude</var></tag-name>
157
<tag-desc>longitude.</tag-desc>
158
159
<tag-name id="var_geoip_region"><var>$geoip_region</var></tag-name>
160
<tag-desc>
161
two-symbol country region code (region, territory, state, province, federal land
162
and the like), for example,
163
<literal>48</literal>”, “<literal>DC</literal>”.
164
</tag-desc>
165
166
<tag-name id="var_geoip_region_name"><var>$geoip_region_name</var></tag-name>
167
<tag-desc>
168
country region name (region, territory, state, province, federal land
169
and the like), for example,
170
<literal>Moscow City</literal>”, “<literal>District of Columbia</literal>”.
171
</tag-desc>
172
173
<tag-name id="var_geoip_city"><var>$geoip_city</var></tag-name>
174
<tag-desc>
175
city name, for example,
176
<literal>Moscow</literal>”, “<literal>Washington</literal>”.
177
</tag-desc>
178
179
<tag-name id="var_geoip_postal_code"><var>$geoip_postal_code</var></tag-name>
180
<tag-desc>
181
postal code.
182
</tag-desc>
183
184
</list>
185
</para>
186
187
</directive>
188
189
190
<directive name="geoip_org">
191
<syntax><value>file</value></syntax>
192
<default/>
193
<context>stream</context>
194
195
<para>
196
Specifies a database used to determine the organization
197
depending on the client IP address.
198
The following variable is available when using this database:
199
<list type="tag">
200
201
<tag-name id="var_geoip_org"><var>$geoip_org</var></tag-name>
202
<tag-desc>
203
organization name, for example, “The University of Melbourne”.
204
</tag-desc>
205
206
</list>
207
</para>
208
209
</directive>
210
211
</section>
212
213
</module>
214
215