Nginx设置只允许来自Cloudflare CDN的IP访问的方法
宝塔NGINX网站只允许CF IP访问方法:
在网站设置里面,配置文件,放置在server里面
location / {
allow 173.245.48.0/20;
allow 103.21.244.0/22;
allow 103.22.200.0/22;
allow 103.31.4.0/22;
allow 141.101.64.0/18;
allow 108.162.192.0/18;
allow 190.93.240.0/20;
allow 188.114.96.0/20;
allow 197.234.240.0/22;
allow 198.41.128.0/17;
allow 162.158.0.0/15;
allow 104.16.0.0/12;
allow 172.64.0.0/13;
allow 131.0.72.0/22;
allow 2400:cb00::/32;
allow 2606:4700::/32;
allow 2803:f800::/32;
allow 2405:b500::/32;
allow 2405:8100::/32;
allow 2a06:98c0::/29;
allow 2c0f:f248::/32;
deny all;
}
注意一个sever里只能有一个location /,如果有多个,请合并!
cloudflare ipv4:https://www.cloudflare.com/ips-v4
cloudflare ipv6:https://www.cloudflare.com/ips-v6
cloudflare ipv4&ipv6:https://www.cloudflare.com/ips
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。