全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
楼主: a276229381

[Windows VPS] 通过CLOUDFLARE屏蔽国家代码。

[复制链接]
发表于 2016-11-6 23:55:32 | 显示全部楼层
用DNS解析屏蔽算么
发表于 2016-11-7 00:01:47 | 显示全部楼层
javascript 的比较好用

[script type="text/javascript"]
$(document).ready(function () {
jQuery.ajax({
url: 'http://freegeoip.net/json/',
type: 'POST',
dataType: 'jsonp',
success: function (location) {
if (location.country_code == '国家代码比如VN') {
window.top.location.href = '自定义禁止页面';
}
}
});
});
[/script]
 楼主| 发表于 2016-11-7 00:24:05 | 显示全部楼层
ANYMOZ 发表于 2016-11-7 00:01
javascript 的比较好用

[script type="text/javascript"]

这个是放在NGINX的配置文件吗?还是在HTML页面调用这个JS?
 楼主| 发表于 2016-11-7 00:47:57 | 显示全部楼层
ANYMOZ 发表于 2016-11-7 00:01
javascript 的比较好用

[script type="text/javascript"]

哦。。。谢谢。。有什么办法不让他访问吗  或者禁止。。这个方法网页是可以打开的。
发表于 2016-11-7 00:53:18 | 显示全部楼层
本帖最后由 guyusoftware 于 2016-11-7 00:55 编辑
a276229381 发表于 2016-11-6 23:02
我是WDCP  我修改的  www/wdlinux/nginx/conf/vhost/www.123.com.conf


Note: You must retrieve the IP Geolocation information from the CF-IPCountry HTTP header.
文章裡的是 HTTP_CF_IPCOUNTRY
你在用教學的時候 也得看看是否一樣啊.............


現在:
1.jpg (47.02 KB, 下载次数: 0)
以前:
2.jpg (40.58 KB, 下载次数: 0)
 楼主| 发表于 2016-11-7 01:14:14 | 显示全部楼层
guyusoftware 发表于 2016-11-7 00:53
Note: You must retrieve the IP Geolocation information from the CF-IPCountry HTTP header.
文章裡的 ...

我把    map $http_cf_ipcountry $allow {   改为 cf_ipcountry  一样屏蔽不了哇。。大神
  
发表于 2016-11-7 01:16:58 | 显示全部楼层
https://support.cloudflare.com/hc/en-us/articles/200170986-How-does-CloudFlare-handle-HTTP-Request-headers-

  1. Fourth Exception: CF-IPCountry

  2. This header holds the country code of the originating visitor, it is a two character value that will have the Country code, if the country code is unknown, it will be "XX".

  3. "Cf-Ipcountry: US"
复制代码
发表于 2016-11-7 01:19:38 | 显示全部楼层
本帖最后由 DeepSkyFire 于 2016-11-7 01:41 编辑
a276229381 发表于 2016-11-6 23:02
我是WDCP  我修改的  www/wdlinux/nginx/conf/vhost/www.123.com.conf




        if ($http_cf-ipcountry ~* (CN|KP|VN|JP)){
        return 403;
        }

你就别再问了,我之前已经给你过一个确定能用的PHP代码,你自己不用也不会去搜。所以你就别再问我这代码加哪里去了。我能做的就只能做到这了。拜拜。
 楼主| 发表于 2016-11-7 01:50:07 | 显示全部楼层
DeepSkyFire 发表于 2016-11-7 01:19
if ($http_cf-ipcountry ~* (CN|KP|VN|JP)){
        return 403;
        }

虽然不好意思。。但是我还是想问一下。。
server {
        listen       80;
        root /www/web/123_com/public_html;
        server_name 123.com;
        index  index.html index.php index.htm;
        error_page  400 /errpage/400.html;
        error_page  403 /errpage/403.html;
        error_page  404 /errpage/4041.html;
        error_page  503 /errpage/503.html;
        location ~ \.php$ {
                proxy_pass http://127.0.0.1:88;
                include naproxy.conf;
        }
        location ~ /\.ht {
                deny  all;
        }
        location / {
                try_files $uri @apache;
        }
        location @apache {
                 proxy_pass http://127.0.0.1:88;
                 include naproxy.conf;
        }  

if ($HTTP_CF-IPCountry ~* (CN|KP|VN|JP)){
        return 403;
        }   
      
         
}


加上去之后。。还是可以访问网站 根本无效啊。。你说的PHP代码 我测试过了 也搜了相关资料。快几个月了。没结果。。我肯定是搜了教程的。
 楼主| 发表于 2016-11-7 01:54:22 | 显示全部楼层
DeepSkyFire 发表于 2016-11-7 01:19
if ($http_cf-ipcountry ~* (CN|KP|VN|JP)){
        return 403;
        }

是不是因为我用WDCP的关系。。

error_page  404 /errpage/4041.html;

我修改错误404指向到4041.html 但是他依然用原来的404.html  我修改之后重启过服务器了。还是不生效。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-4-27 20:22 , Processed in 0.071361 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表