不允许中国用户访问网站
环境:centos 6.4 + php5.5 + nginx
nginx配置中,在location / { }中增加一行
include “网站路径/.htaccess”;
放第一行即可。
.htaccess的内容为:
deny 禁止的IP网段;
大概有2300多个网段。为了方便大家,我把.htaccess压缩包提供下载。下载地址
反向代理中也可以使用,配置内容如下
[sourcecode language=”plain”]
server
{
listen 80;server_name 域名;
location / {
include "/网站目录/.htaccess";
proxy_pass http://域名/或者IP; #反代的网站
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
access_log /日志目录/日志名称 access;
}
[/sourcecode]
噢!评论已关闭。