Nginx 拒绝国外IP访问

给予访问域名限制

Nginx 给予deny禁止国外IP地址访问

从: http://ftp.apnic.net/apnic/stats/apnic/legacy-apnic-latest(会自动实时更新数据) 拿到对应的IP地址系统/运维

获取IP地址命令

wget http://ftp.net是什么语言.apnic.net/apnic/stats/apnic/legacy-apni系统/运维c-latest

awk -F '|' '{if(NR>2)printf("%s %s/%d%s\n","",$4,24,"")}' legacy-apnic-latest >> /usr/local/nginx/conf/deny_host.conf

然后处理Nglinux系统安装inx配置文件引入deny_host.conf文件

s炮灰婆婆的人生erver {

listen 80;

server_name han.com;

access_log /data/wwwlogs/dev_access_nginx.log main;

error_log /data/wwwlogs/dev_error_nginx.log;

root /mnt/han/public;

index index.html index.htm innginx安装与配置详解dex.php;

include deny_host.conf;

if (!-e $request_filename){

rewrite (.*) /inde.net是干嘛的x.php last;

}

location ~ [^/]\.php(/|$) {

fastcgi_passphp是什么语言 unix:/data/phpsock/pnginx安装与配置详解hp-cgi.sock;

fastcgi_index index.php;

include fastcgi.conf;

error_page 405 =200 http://han.com;

}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {

expires 30d;

access_log off;

}

location系统/运维 ~ .*\.(js|css)?$ {

expires 7d;

access_log off;

}

locatlinux是什么操作系统ion ~ /\.ht {

deny all;

}

}

重新载入Nginx服务

nginx -s reload

最好是写成定时任务来自动处理

定时任务脚本

0 1 * * 1 /bin/bash /data/sh/Nphp是前端还是后端ginx_deny_IP.sh > /dev/null 2>&1

#!/nginxbin/bash

IP_dir="/data/"

link="http://ftp.apnic.net/apnic/stats/apnic/legacy-apnic-latest"

cd $Iphp是什么P_dir

rm $IP_dir/legacy-apnic-latest && wget $link

awk -F '|' '{if(NR>2)printf("%s %s/%d%s\n","",$4,24,""nginx是什么意思)}' lega.net是干嘛的cy-apnic-latest > /usr/local/nginx/conf/deny_hophpst.conf

nginx -t

nginx -s reload