FAQ

Page Discussion Edit History

ChsHttpGeoModule

(Redirected from NginxChsHttpGeoModule)

Contents

[edit] 鎽樿

杩欎釜妯″潡鍒涘缓涓浜涘彉閲忥紝鍏跺间緷璧栦簬瀹㈡埛绔殑IP鍦板潃.

绀轰緥閰嶇疆:

geo  $geo  {
  default          0;
  127.0.0.1/32     2;
  192.168.1.0/24   1;
  10.1.0.0/16      1;
}

[edit] 鎸囦护

[edit] geo

璇硶: geo [$ip_variable] $variable { ... }

榛樿鍊: none

璇: http

杩欎釜鎸囦护鎸囧畾浜嗕竴涓鎴风IP鐨勬墍灞炲浗瀹讹紝榛樿鎯呭喌涓嬪畠浼氭煡鎵$remote_addr鍙橀噺锛屼絾鍦0.7.27鐗 鏈互鍚庡彲浠ユ墜宸ユ寚瀹氥

 geo  $arg_remote_addr $geo {
   ...;
 }

浣跨敤CIDR鍦板潃鏍煎紡锛屽彟澶栵紝鏈4涓壒娈婄殑鍙傛暟:

绀轰緥璇存槑:

  • delete 鈥 鍒犻櫎鎸囧畾鐨勭綉缁 (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; 
 }

[edit] 鍙傝

鍘熷淇勬枃鏂囨。 鍘熷鑻辨枃wiki鏂囨。