### Geo模塊
### 摘要
This module creates variables, whose values depend on the IP-address of the client.
Example configuration:
~~~
geo $geo {
default 0;
127.0.0.1/32 2;
192.168.1.0/24 1;
10.1.0.0/16 1;
}
~~~
### 指令
### geo
**syntax:***geo [$ip_variable] $variable { ... }*
**default:** none
**context:***http*
The directive describes the dependency of the value of a variable on the IP-address of a client. By default, the IP-address used for the lookup is $remote_addr, but since version 0.7.27 it is possible to specify which variable should be used.
~~~
geo $arg_remote_addr $geo {
...;
}
~~~
Addresses are assigned in the form CIDR. Furthermore, there are four special parameters:
Example of the description:
- delete – deletes the specified network (0.7.23).
- default - the value of variable, if the client address does not correspond to any assigned address. It is possible so to write instead of default 0.0.0.0/0.
- include - text file with addresses and values information. Several files can be inluded like this.
- proxy - specifies the address of proxy server (0.8.7+). NEED MORE DESCRIPTION...
- ranges – specifies that the addresses specified are in the form of ranges (0.7.23). This directive must be the first.
~~~
geo $country {
default no;
include conf/geo.conf;
127.0.0.0/24 us;
127.0.0.1/32 ru;
10.1.0.0/16 ru;
192.168.1.0/24 uk;
}
~~~
In the file conf/geo.conf:
~~~
10.2.0.0/16 ru;
192.168.2.0/24 ru;
~~~
The value will be the the one with maximum agreement. For example, the IP address 127.0.0.1 will get the value "ru", but not "us".
Example with ranges:
~~~
geo $country {
ranges;
default no;
127.0.0.0-127.0.0.0 us;
127.0.0.1-127.0.0.1 ru;
127.0.0.1-127.0.0.255 us;
10.1.0.0-10.1.255.255 ru;
192.168.1.0-192.168.1.255 uk;
}
~~~
### References
- [HWLoadbalancerCheckErrors](http://doc.aiwaly.com/HWLoadbalancerCheckErrors "HWLoadbalancerCheckErrors")
- [Creating geo.conf From MaxMind GeoIP Country Database](http://www.ruby-forum.com/topic/125810 "http://www.ruby-forum.com/topic/125810")
- [Original Documentation](http://sysoev.ru/nginx/docs/http/ngx_http_geo_module.html "http://sysoev.ru/nginx/docs/http/ngx_http_geo_module.html")
- 主要文檔
- Nginx功能概述
- 為什么選擇Nginx
- Nginx安裝
- 運行和控制Nginx
- 配置符號參考
- 優化 Nginx
- 常見問題(FAQ)
- 調試 nginx
- 核心模塊
- Nginx主模塊
- Nginx事件模塊
- 基本模塊
- http核心模塊
- HttpIndex模塊
- HttpAccess模塊
- HttpAuthBasic模塊
- HttpAutoindex模塊
- Browser模塊
- Charset模塊
- HttpEmptyGif模塊
- HttpFcgi模塊
- Geo模塊
- HttpGzip模塊
- HttpHeaders模塊
- HttpIndex模塊
- HttpReferer模塊
- HttpLimit zone
- HttpLimitReqest模塊
- HttpLog模塊
- map
- Memcached
- HttpProxy模塊
- HttpRewrite模塊
- HttpSSI模塊
- HttpUserId
- 其他模塊
- Addition模塊
- EmbeddedPerl
- flv
- HttpGzipStatic
- RandomIndex
- HttpGeoIP
- HttpRealIp
- HttpSSL
- StubStatus模塊
- HttpSubstitution
- HttpDav模塊
- GooglePerftools
- HttpXSLT
- HttpSecureLink
- HttpImageFilter
- mail模塊
- MailCore
- MailAuth
- MailProxy
- MailSSL
- 安裝
- nginx在windows上的安裝
- nginx在freebsd上的安裝
- nginx在ubuntu上的安裝
- nginx在fedora上的安裝
- nginx php-fpm安裝配置
- 配置示例和方法
- 完整例子
- 完整例子2
- 虛擬主機
- 負載均衡
- nginx防盜鏈
- HWLoadbalancerCheckErrors