Path: blob/main/xml/en/docs/http/ngx_http_geoip_module.xml
1 views
<?xml version="1.0"?>12<!--3Copyright (C) Igor Sysoev4Copyright (C) Nginx, Inc.5-->67<!DOCTYPE module SYSTEM "../../../../dtd/module.dtd">89<module name="Module ngx_http_geoip_module"10link="/en/docs/http/ngx_http_geoip_module.html"11lang="en"12rev="5">1314<section id="summary">1516<para>17The <literal>ngx_http_geoip_module</literal> module (0.8.6+) creates variables18with values depending on the client IP address, using the precompiled19<link url="http://www.maxmind.com">MaxMind</link> databases.20</para>2122<para>23When using the databases with IPv6 support (1.3.12, 1.2.7),24IPv4 addresses are looked up as IPv4-mapped IPv6 addresses.25</para>2627<para>28This module is not built by default, it should be enabled with the29<literal>--with-http_geoip_module</literal>30configuration parameter.31<note>32This module requires the33<link url="http://www.maxmind.com/app/c">MaxMind GeoIP</link> library.34</note>35</para>3637</section>383940<section id="example" name="Example Configuration">4142<para>43<example>44http {45geoip_country GeoIP.dat;46geoip_city GeoLiteCity.dat;47geoip_proxy 192.168.100.0/24;48geoip_proxy 2001:0db8::/32;49geoip_proxy_recursive on;50...51</example>52</para>5354</section>555657<section id="directives" name="Directives">5859<directive name="geoip_country">60<syntax><value>file</value></syntax>61<default/>62<context>http</context>6364<para>65Specifies a database used to determine the country66depending on the client IP address.67The following variables are available when using this database:68<list type="tag">6970<tag-name id="var_geoip_country_code"><var>$geoip_country_code</var></tag-name>71<tag-desc>72two-letter country code, for example,73“<literal>RU</literal>”, “<literal>US</literal>”.74</tag-desc>7576<tag-name id="var_geoip_country_code3"><var>$geoip_country_code3</var>77</tag-name>78<tag-desc>79three-letter country code, for example,80“<literal>RUS</literal>”, “<literal>USA</literal>”.81</tag-desc>8283<tag-name id="var_geoip_country_name"><var>$geoip_country_name</var></tag-name>84<tag-desc>85country name, for example,86“<literal>Russian Federation</literal>”, “<literal>United States</literal>”.87</tag-desc>8889</list>90</para>9192</directive>939495<directive name="geoip_city">96<syntax><value>file</value></syntax>97<default/>98<context>http</context>99100<para>101Specifies a database used to determine the country, region, and city102depending on the client IP address.103The following variables are available when using this database:104<list type="tag">105106<tag-name id="var_geoip_area_code"><var>$geoip_area_code</var></tag-name>107<tag-desc>telephone area code (US only).108<note>109This variable may contain outdated information since110the corresponding database field is deprecated.111</note>112</tag-desc>113114<tag-name id="var_geoip_city_continent_code">115<var>$geoip_city_continent_code</var></tag-name>116<tag-desc>two-letter continent code, for example,117“<literal>EU</literal>”, “<literal>NA</literal>”.118</tag-desc>119120<tag-name id="var_geoip_city_country_code"><var>$geoip_city_country_code</var>121</tag-name>122<tag-desc>123two-letter country code, for example,124“<literal>RU</literal>”, “<literal>US</literal>”.125</tag-desc>126127<tag-name id="var_geoip_city_country_code3"><var>$geoip_city_country_code3</var>128</tag-name>129<tag-desc>130three-letter country code, for example,131“<literal>RUS</literal>”, “<literal>USA</literal>”.132</tag-desc>133134<tag-name id="var_geoip_city_country_name"><var>$geoip_city_country_name</var>135</tag-name>136<tag-desc>137country name, for example,138“<literal>Russian Federation</literal>”, “<literal>United States</literal>”.139</tag-desc>140141<tag-name id="var_geoip_dma_code"><var>$geoip_dma_code</var></tag-name>142<tag-desc>143DMA region code in US (also known as “metro code”), according to the144<link url="https://developers.google.com/adwords/api/docs/appendix/cities-DMAregions">geotargeting</link>145in Google AdWords API.146</tag-desc>147148<tag-name id="var_geoip_latitude"><var>$geoip_latitude</var></tag-name>149<tag-desc>latitude.</tag-desc>150151<tag-name id="var_geoip_longitude"><var>$geoip_longitude</var></tag-name>152<tag-desc>longitude.</tag-desc>153154<tag-name id="var_geoip_region"><var>$geoip_region</var></tag-name>155<tag-desc>156two-symbol country region code (region, territory, state, province, federal land157and the like), for example,158“<literal>48</literal>”, “<literal>DC</literal>”.159</tag-desc>160161<tag-name id="var_geoip_region_name"><var>$geoip_region_name</var></tag-name>162<tag-desc>163country region name (region, territory, state, province, federal land164and the like), for example,165“<literal>Moscow City</literal>”, “<literal>District of Columbia</literal>”.166</tag-desc>167168<tag-name id="var_geoip_city"><var>$geoip_city</var></tag-name>169<tag-desc>170city name, for example,171“<literal>Moscow</literal>”, “<literal>Washington</literal>”.172</tag-desc>173174<tag-name id="var_geoip_postal_code"><var>$geoip_postal_code</var></tag-name>175<tag-desc>176postal code.177</tag-desc>178179</list>180</para>181182</directive>183184185<directive name="geoip_org">186<syntax><value>file</value></syntax>187<default/>188<context>http</context>189<appeared-in>1.0.3</appeared-in>190191<para>192Specifies a database used to determine the organization193depending on the client IP address.194The following variable is available when using this database:195<list type="tag">196197<tag-name id="var_geoip_org"><var>$geoip_org</var></tag-name>198<tag-desc>199organization name, for example, “The University of Melbourne”.200</tag-desc>201202</list>203</para>204205</directive>206207208<directive name="geoip_proxy">209<syntax><value>address</value> | <value>CIDR</value></syntax>210<default/>211<context>http</context>212<appeared-in>1.3.0</appeared-in>213<appeared-in>1.2.1</appeared-in>214215<para>216Defines trusted addresses.217When a request comes from a trusted address,218an address from the <header>X-Forwarded-For</header> request219header field will be used instead.220</para>221222</directive>223224225<directive name="geoip_proxy_recursive">226<syntax><literal>on</literal> | <literal>off</literal></syntax>227<default>off</default>228<context>http</context>229<appeared-in>1.3.0</appeared-in>230<appeared-in>1.2.1</appeared-in>231232<para>233If recursive search is disabled then instead of the original client234address that matches one of the trusted addresses, the last235address sent in <header>X-Forwarded-For</header> will be used.236If recursive search is enabled then instead of the original client237address that matches one of the trusted addresses, the last238non-trusted address sent in <header>X-Forwarded-For</header> will be used.239</para>240241</directive>242243</section>244245</module>246247248