非常教程

Nginx参考手册

ngx_http_geoip_module

ngx_http_geoip_module

  • 示例配置
  • 指令
  • geoip_country
  • geoip_city
  • geoip_org
  • geoip_proxy
  • geoip_proxy_recursive

所述ngx_http_geoip_module模块(0.8.6+)与根据客户端的IP地址值,并使用预编译的创建变量的MaxMind数据库。

当使用支持IPv6的数据库时(1.3.12,1.2.7),IPv4地址将被视为IPv4映射的IPv6地址。

该模块不是默认生成的,它应该使用--with-http_geoip_module配置参数启用。

该模块需要MaxMind GeoIP库。

示例配置

http {
    geoip_country         GeoIP.dat;
    geoip_city            GeoLiteCity.dat;
    geoip_proxy           192.168.100.0/24;
    geoip_proxy           2001:0db8::/32;
    geoip_proxy_recursive on;
    ...

指令

句法:

geoip_country文件;

默认:

语境:

HTTP

指定用于根据客户端IP地址确定国家/地区的数据库。使用此数据库时,以下变量可用:

$ geoip_country_code双字母国家代码,例如“RU”,“US”。 $ geoip_country_code3三个字母的国家代码,例如“RUS”,“USA”。 $ geoip_country_name国名,例如“Russian Federation”, “United States”.

句法:

geoip_city文件;

默认:

语境:

HTTP

指定用于根据客户端IP地址确定国家,地区和城市的数据库。使用此数据库时,以下变量可用:

$geoip_area_code电话区号(仅限美国)。

由于相应的数据库字段已弃用,因此此变量可能包含过时的信息。

$geoip_city_continent_code两个字母的大陆代码,例如“ EU”,“ NA”。$geoip_city_country_code双字母国家代码,例如“ RU”,“ US”。$geoip_city_country_code3三个字母的国家代码,例如“ RUS”,“ USA”。$geoip_city_country_name国名,例如“ Russian Federation”,“ United States”。$geoip_dma_code根据Google AdWords API中的地理位置定位,美国的DMA地区代码(也称为“城市代码”)。$geoip_latitude纬度。$geoip_longitude经度。$geoip_region符号国家地区代码(地区,地区,州,省,联邦土地等),例如“ 48”,“ DC”。$geoip_region_name国家地区名称(地区,领土,州,省,联邦土地等),例如“ Moscow City”,“ District of Columbia”。$geoip_city城市名称,例如“ Moscow”,“ Washington”。$geoip_postal_code邮政编码。

句法:

geoip_org文件;

默认:

语境:

HTTP

指定用于根据客户端IP地址确定组织的数据库。使用此数据库时,以下变量可用:

$geoip_org 组织名称,例如“墨尔本大学”。

句法:

geoip_proxy地址| CIDR;

默认:

语境:

HTTP

定义可信地址。当请求来自可信地址时,将使用来自“X-Forwarded-For”请求标题字段的地址。

句法:

geoip_proxy_recursive 开启|关闭;

默认:

geoip_proxy_recursive off;

语境:

HTTP

如果递归搜索被禁用,那么将使用在“X-Forwarded-For”中发送的最后一个地址,而不是匹配其中一个可信地址的原始客户端地址。如果启用递归搜索,则将使用在“X-Forwarded-For”中发送的最后一个不可信地址,而不是匹配其中一个可信地址的原始客户端地址。

ngx_http_geoip_module
Nginx

Nginx是一款轻量级的 Web 服务器/反向代理服务器及电子邮件代理服务器,可在 BSD-like 协议下发行。其特点是占有内存少,并发能力强。

主页 https://nginx.org/
源码 http://hg.nginx.org/nginx
发布版本 1.13.6

Nginx目录

1.指南 | Guides
2.核心 | Core
3.ngx_google_perftools_module
4.ngx_http_access_module
5.ngx_http_addition_module
6.ngx_http_api_module
7.ngx_http_auth_basic_module
8.ngx_http_auth_jwt_module
9.ngx_http_auth_request_module
10.ngx_http_autoindex_module
11.ngx_http_browser_module
12.ngx_http_charset_module
13.ngx_http_core_module
14.ngx_http_dav_module
15.ngx_http_empty_gif_module
16.ngx_http_f4f_module
17.ngx_http_fastcgi_module
18.ngx_http_flv_module
19.ngx_http_geoip_module
20.ngx_http_geo_module
21.ngx_http_gunzip_module
22.ngx_http_gzip_module
23.ngx_http_gzip_static_module
24.ngx_http_headers_module
25.ngx_http_hls_module
26.ngx_http_image_filter_module
27.ngx_http_index_module
28.ngx_http_js_module
29.ngx_http_keyval_module
30.ngx_http_limit_conn_module
31.ngx_http_limit_req_module
32.ngx_http_log_module
33.ngx_http_map_module
34.ngx_http_memcached_module
35.ngx_http_mirror_module
36.ngx_http_mp4_module
37.ngx_http_perl_module
38.ngx_http_proxy_module
39.ngx_http_random_index_module
40.ngx_http_realip_module
41.ngx_http_referer_module
42.ngx_http_rewrite_module
43.ngx_http_scgi_module
44.ngx_http_secure_link_module
45.ngx_http_session_log_module
46.ngx_http_slice_module
47.ngx_http_spdy_module
48.ngx_http_split_clients_module
49.ngx_http_ssi_module
50.ngx_http_ssl_module
51.ngx_http_status_module
52.ngx_http_stub_status_module
53.ngx_http_sub_module
54.ngx_http_upstream_conf_module
55.ngx_http_upstream_hc_module
56.ngx_http_upstream_module
57.ngx_http_userid_module
58.ngx_http_uwsgi_module
59.ngx_http_v2_module
60.ngx_http_xslt_module
61.ngx_mail_auth_http_module
62.ngx_mail_core_module
63.ngx_mail_imap_module
64.ngx_mail_pop3_module
65.ngx_mail_proxy_module
66.ngx_mail_smtp_module
67.ngx_mail_ssl_module
68.ngx_stream_access_module
69.ngx_stream_core_module
70.ngx_stream_geoip_module
71.ngx_stream_geo_module
72.ngx_stream_js_module
73.ngx_stream_limit_conn_module
74.ngx_stream_log_module
75.ngx_stream_map_module
76.ngx_stream_proxy_module
77.ngx_stream_realip_module
78.ngx_stream_return_module
79.ngx_stream_split_clients_module
80.ngx_stream_ssl_module
81.ngx_stream_ssl_preread_module
82.ngx_stream_upstream_hc_module
83.ngx_stream_upstream_module