nginx 禁止and放行IP,IP段
禁止某个IP
deny 192.168.0.104;
禁止某个IP段
deny 192.168.0.1/24;
允许某个ip
allow 192.168.0.104;
deny all;
允许某个ip段
allow 192.168.0.1/24;
deny all;
例子
server {
listen 80;
server_name myweb;
#allow 192.168.0.1/24; 允许这个段
#deny all; 其他全部禁止
location / {
root /usr/share/nginx/html/test;
index index.html index.htm;
}
}
例子2
allow ;
#sogou
allow 106.120.0.0/16;
allow 106.38.0.0/16;
allow 111.202.0.0/16;
allow 123.126.0.0/16;
allow 162.158.0.0/16;
allow 172.68.0.0/16;
allow 172.69.0.0/16;
allow 49.7.0.0/16;
allow 58.250.0.0/16;
allow 220.181.125.0/24;
allow 123.126.51.64/27;
allow 123.126.51.96/28;
allow 123.126.68.25;
allow 61.135.189.74;
allow 61.135.189.75;
#baidu
allow 180.76.15.0/24;
allow 119.63.196.0/24;
allow 115.239.212./24;
allow 119.63.199.0/24;
allow 122.81.208.0/22;
allow 123.125.71.0/24;
allow 180.76.4.0/24;
allow 180.76.5.0/24;
allow 180.76.6.0/24;
allow 185.10.104.0/24;
allow 220.181.108.0/24;
allow 220.181.51.0/24;
allow 111.13.102.0/24;
allow 123.125.67.144/29;
allow 123.125.67.152/31;
allow 61.135.169.0/24;
allow 123.125.68.68/30;
allow 123.125.68.72/29;
allow 123.125.68.80/28;
allow 123.125.68.96/30;
allow 202.46.48.0/20;
allow 220.181.38.0/24;
allow 123.125.68.80/30;
allow 123.125.68.84/31;
allow 123.125.68.0/24;
allow 107.161.0.0/16;
allow 107.191.0.0/16;
allow 111.206.0.0/16;
allow 123.125.0.0/16;
allow 124.166.0.0/16;
allow 220.181.0.0/16;
allow 23.226.0.0/16;
#sm
allow 42.156.136.0/24;
allow 42.156.137.0/24;
allow 42.156.138.0/24;
allow 42.156.139.0/24;
allow 42.120.160.0/24;
allow 42.120.161.0/24;
allow 42.156.254.0/24;
allow 42.120.234.0/24;
allow 42.120.235.0/24;
allow 42.120.236.0/24;
allow 106.11.152.0/24;
allow 106.11.153.0/24;
allow 106.11.154.0/24;
allow 106.11.155.0/24;
allow 106.11.156.0/24;
allow 106.11.157.0/24;
allow 106.11.158.0/24;
allow 106.11.159.0/24;
#360
allow 42.236.10.0/24;
allow 42.236.12.0/24;
allow 42.236.13.0/24;
allow 42.236.14.0/24;
allow 42.236.15.0/24;
allow 42.236.16.0/24;
allow 42.236.17.0/24;
allow 42.236.46.0/24;
allow 42.236.48.0/24;
allow 42.236.49.0/24;
allow 42.236.50.0/24;
allow 42.236.51.0/24;
allow 42.236.52.0/24;
allow 42.236.53.0/24;
allow 42.236.54.0/24;
allow 42.236.55.0/24;
allow 42.236.99.0/24;
allow 42.236.101.0/24;
allow 42.236.102.0/24;
allow 42.236.103.0/24;
allow 180.153.232.0/24;
allow 180.153.234.0/24;
allow 180.153.236.0/24;
allow 180.163.220.0/24;
#今日头条
allow 110.249.201.0/24;
allow 110.249.202.0/24;
allow 111.225.148.0/24;
allow 111.225.149.0/24;
allow 220.243.135.0/24;
allow 220.243.136.0/24;
#全部访问
deny all;
error_page 403 /403.html;
location /403.html {
allow all;
}