奥门威尼斯网址PHP幸免个别IP访问网址

想不让某个IP访问网站,可以封他的IP,下面就提供这个方法。看下面的代码。
复制代码 代码如下:
function get_ip_data(){  
   
$ip=file_get_contents(“));
    $ip = json_decode($ip);
    if($ip->code){
        return false;
    }
    $data = (array) $ip->data;
    if($data[‘region’]==’湖北省’ && !isCrawler()){
        exit(”);
    }
}

  今天吴总在百度快照里头发现www.cut.cn也能访问商城网站。

需要禁止IP访问网站.在相关的server中设置相关的限制即可.

function isCrawler() {
        $spiderSite= array(
                        “TencentTraveler”,
                        “Baiduspider+”,
                        “BaiduGame”,
                        “Googlebot”,
                        “msnbot”,
                        “Sosospider+”,
                        “Sogou web spider”,
                        “ia_archiver”,
                        “Yahoo! Slurp”,
                        “YoudaoBot”,
                        “Yahoo Slurp”,
                        “MSNBot”,
                        “Java (Often spam bot)”,
                        “BaiDuSpider”,
                        “Voila”,
                        “Yandex bot”,
                        “BSpider”,
                        “twiceler”,
                        “Sogou Spider”,
                        “Speedy Spider”,
                        “Google AdSense”,
                        “Heritrix”,
                        “Python-urllib”,
                        “Alexa (IA Archiver)”,
                        “Ask”,
                        “Exabot”,
                        “Custo”,
                        “OutfoxBot/YodaoBot”,
                        “yacy”,
                        “SurveyBot”,
                        “legs”,
                        “lwp-trivial”,
                        “Nutch”,
                        “StackRambler”,
                        “The web archive (IA Archiver)”,
                        “Perl tool”,
                        “MJ12bot”,
                        “Netcraft”,
                        “MSIECrawler”,
                        “WGet tools”,
                        “larbin”,
                        “Fish search”,
                );
       
if(in_array(strtolower($_SERVER[‘HTTP_USER_AGENT’]),$spiderSite)){
            return true;
        }else{
            return false;
        }
}

  一、我问了域名商,回复说不清楚情况,他们不会去做这种域名指向动作,让我们问服务器托管商。

奥门威尼斯网址 1

//取客户端 ip
function get_client_ip()
{
    if (isset($_SERVER)){
            if (isset($_SERVER[“HTTP_X_FORWARDED_FOR”])){
                $realip = $_SERVER[“HTTP_X_FORWARDED_FOR”];
            } else if (isset($_SERVER[“HTTP_CLIENT_IP”])) {
                $realip = $_SERVER[“HTTP_CLIENT_IP”];
            } else {
                $realip = $_SERVER[“REMOTE_ADDR”];
            }
    } else {
            if (getenv(“HTTP_X_FORWARDED_FOR”)){
                $realip = getenv(“HTTP_X_FORWARDED_FOR”);
            } else if (getenv(“HTTP_CLIENT_IP”)) {
                $realip = getenv(“HTTP_CLIENT_IP”);
            } else {
                $realip = getenv(“REMOTE_ADDR”);
            }
        }
    return $realip;
}

  二、询问服务器托管商,回复说他们没有动过,按访问此域名的表象看,不具备什么“攻击性”,让我再询问一下相关人员是否有绑定域名,另外询问网站厂商是否有绑定域名。且一般情况这种问题属于应用方面的问题,需要我们在网站服务器的配置文件里头配置好就行了。

奥门威尼斯网址 2

  三、询问网站厂商工程师,回复说没有绑定过域名。

 

 

先在  查询了域名是谁的,提示为:

奥门威尼斯网址 3
Ping 的结果:

奥门威尼斯网址 4
  之后没办法,自己动手丰衣足食。

# vim /usr/local/nginx/conf/nginx.conf

在http{}中添加:

server {
listen 80 default;

server_name _;
return 500;
}

# /usr/local/nginx/sbin/nginx -t
the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
configuration file /usr/local/nginx/conf/nginx.conf test is successful

# /usr/local/nginx/sbin/nginx -s reload

解决。

发表评论

电子邮件地址不会被公开。 必填项已用*标注