- 语法
- 允许ip
Syntax:allow address | CIDR |unix | all;Default:--Context:http,server,locaton,limit_except
- 阻止ip
Syntax: deny address | CIDR | unix: | all;Default: --Context: http,server,locaton,limit_except
- 例:/etc/nginx/conf.d/default.conf
server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/host.access.log main; location / { root /usr/share/nginx/html; index index.html index.htm; } location ~ ^/admin.html { root /opt/app/code; deny 192.168.0.116; ##阻止192.168.0.116访问 allow all; ##允许所有 index index.html index.htm; } location ~ ^/1.html { root /opt/app/code; deny 192.168.0.0/116; ##阻止ip段访问 allow all; ##允许所有 index index.html index.htm; } location ~ ^/test.html { root /opt/app/code; deny all; ##阻止 allow 192.168.0.116; ##允许 index index.html index.htm; } #error_page 404 /404.html; ... ...