Nginx implementation of IP-based access control functions: (Ngx_http_access_module)
Official documents: http://nginx.org/en/docs/http/ngx_http_access_module.html
Official Example:
The Ngx_http_access_module module allows limiting access to certain client addresses. Qualified resources are accessed only by the specified clients.
Example configuration:location/{deny 192.168.1.1; #自上而下检测, the matching range is small in the above allow 192.168.1.0/24; Allow 10.1.1.0/16; Allow 2001:0DB8::/32; Deny all;}
syntax: |
Allow address | CIDR | Unix: | all ; |
default: |
- |
context: |
http , server , location , limit_except |
Syntax: |
deny address | CIDR | unix: | all ;
|
Default: |
— |
Context: |
http , server , location ,limit_except
|
Context: Applicable configuration segment
Demo Environment:
Server:192.168.47.140client1:192.168.47.137client2:192.168.47.138[[email protected] ~]# cat/etc/redhat-release CentOS Linux release 7.2.1511 (Core) [[email protected] ~]# uname-r3.10.0-327.el7.x86_64[[email protected] ~]# nginx-v N Ginx version:nginx/1.10.2 ...
Related configuration:
#Server配置:[[email protected] ~]# cat /data/html/server/index.html
This article is from the "gning," blog, please be sure to keep this source http://gning.blog.51cto.com/11847592/1968243
Nginx implements IP-based access control (Ngx_http_access_module module)