月度存档: 三月 2009 - 第2页

IP反向查询工具

现在国内使用wordpress的用户不少,很多采用自建博客后租用虚拟空间,那么空间的服务就很重要,这里介绍一个简单的IP反向查询工具,帮助大家了解一下自己的服务器上同一IP有多少个域名,也就可以了解你的hosting供应商有多黑了。

查询同一IP下不同域名:
$ip=trim($_POST['ip']);
if(!empty($ip) && !eregi("([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})",$ip)){
echo "IP地址格式不正确!请重新输入“;
$ip=”";
}
?>

onMouseOver=”this.focus()” onFocus=”this.select();this.style.color=’#000000′” onClick=”if (this.value==’输入IP’) this.value=”” onblur=”if(this.value ==”||this.value==’输入IP’){this.value=’输入IP’;this.style.color=’#cccccc’}” style=”width: 100px;color:#999999;”>

if (!empty($ip)){
include "Snoopy.class.php";
$snoopy = new Snoopy ( );
$snoopy->agent = “Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)”;
$snoopy->rawheaders ["Pragma"] = “no-cache”;
$snoopy->expandlinks = true;
$refer = “http://www.domaintools.com/reverse-ip/”;
$snoopy->cookies["nisession"] = ‘w4yyoBRKlMOaEuWxuw4mxc9agwAlZGPRjKbzJKmFStw%253D’;
$snoopy->referer = $refer;
//$snoopy->user = “joe”;
//$snoopy->pass = “bloe”;
//$snoopy->rawheaders["X_FORWARDED_FOR"] = “127.0.0.101″;
$snoopy->rawheaders["X-Requested-With"] = “XMLHttpRequest”;

$submit_url = “http://www.domaintools.com/reverse-ip/functions.html?s=preview”;

$submit_vars ["ip"] = $ip;
$submit_vars ["_"] = “”;

if ($snoopy->submit ( $submit_url, $submit_vars )) {
preg_match ( “/

  • (.*)<\/li>/is”, $snoopy->results, $table );
    $art_list=explode(“\n”,trim(strip_tags($table[0])));
    echo “查询结果如下:
      “;
      foreach ( $art_list as $art_node ) {
      $tmp=trim($art_node);
      if (!empty($tmp))
      echo “
    • “. $art_node .”
    • “;
      }
      echo “

    “;
    } else
    echo “error fetching document: ” . $snoopy->error . “\n”;
    }//end of if empty ip
    ?>
    该IP的反向查询主机信息:

    你也可以使用如下IP反向查询多个域名的工具

    http://www.find-ip-address.org/reverse_lookup/

    http://www.myipneighbors.com/ 这个好像已经被黑掉了
    如果你用的是虚拟主机,要注意防范旁注攻击

    VN:F [1.9.14_1148]
    Rating: 0.0/10 (0 votes cast)
    VN:F [1.9.14_1148]
    Rating: 0 (from 0 votes)
  • NGINX 502错误排查

    502 Bad Gateway错误是FastCGI有问题,造成NGINX 502错误的可能性比较多。将网上找到的一些和502 Bad Gateway错误有关的问题和排查方法列一下,先从FastCGI配置入手:

    1.查看FastCGI进程是否已经启动
    NGINX 502错误的含义是sock、端口没被监听造成的。我们先检查fastcgi是否在运行

    2.检查系统Fastcgi进程运行情况
    除了第一种情况,fastcgi进程数不够用、php执行时间长、或者是php-cgi进程死掉也可能造成nginx的502错误
    运行以下命令判断是否接近FastCGI进程,如果fastcgi进程数接近配置文件中设置的数值,表明worker进程数设置太少
    netstat -anpo | grep "php-cgi" | wc -l

    3.FastCGI执行时间过长
    根据实际情况调高以下参数值
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;

    4.头部太大
    nginx和apache一样,有前端缓冲限制,可以调整缓冲参数
    fastcgi_buffer_size 32k;
    fastcgi_buffers 8 32k;
    如果你使用的是nginx的负载均衡Proxying,调整
    proxy_buffer_size  16k;
    proxy_buffers      4 16k;
    参见:http://www.ruby-forum.com/topic/169040

    5.https转发配置错误
    正确的配置方法
    server_name www.mydomain.com;
    location /myproj/repos {
    set $fixed_destination $http_destination;
    if ( $http_destination ~* ^https(.*)$ )
    {
    set $fixed_destination http$1;
    }
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Destination $fixed_destination;
    proxy_pass http://subversion_hosts;
    }

    参见:http://www.ruby-forum.com/topic/169040

    当然,还要看你后端用的是哪种类型的FastCGI,我用过的有php-fpm,流量约为单台机器40万PV(动态页面), 现在基本上没有碰到502。

    VN:F [1.9.14_1148]
    Rating: 8.6/10 (7 votes cast)
    VN:F [1.9.14_1148]
    Rating: 0 (from 0 votes)

    Zencart持久链接的Nginx rewrite规则

    前几天介绍了如何在nginx下作wordpress的伪静态化Joomla的SEF模块设置。今天顺便介绍下如何在nginx下来做zencart的url伪静态化呢? 这里我们对这个过程做个假单的介绍,首先我们假设你使用的是zencart的Ultimate SEO URLs模块,并且已经安装和设置好了该插件。那么现在我们需要做的就是为zencart建立一个nginx的rewrite规则,具体操作方法如下,首先新建一个文件your__path/conf/zencart_rewrite.conf, 建立如下:
            # if the requested file exists, return it immediately
            if (-f $request_filename) {
                    break;
            }

            rewrite "^/(.*)-p-(.*).html$" /index.php?main_page=product_info&products_id=$2&% last;
            rewrite "^/(.*)-c-(.*).html$" /index.php?main_page=index&cPath=$2&% last;
            rewrite "^/(.*)-m-([0-9]+).html$" /index\.php?main_page=index&manufacturers_id=$2&% last;
            rewrite "^/(.*)-pi-([0-9]+).html$" /index\.php?main_page=popup_image&pID=$2&% last;
            rewrite "^/(.*)-pr-([0-9]+).html$" /index\.php?main_page=product_reviews&products_id=$2&% last;
            rewrite "^/(.*)-pri-([0-9]+).html$" /index\.php?main_page=product_reviews_info&products_id=$2&% last;
            # For wordpress on zencart by Jeff
            rewrite "^/wp/(.*).html$" /index.php?main_page=wordpress&page_id=$1&% last;

            # For eazy pages
            rewrite "^/(.*)-ezp-([0-9]+).html$" /index\.php?main_page=page&id=$2&% last;

            # For Open Operations Info Manager
            rewrite "^(.*)-i-([0-9]+).html" /index.php?main_page=info_manager&pages_id=$2&% last;

            # For dreamscape¡¯s News & Articles Manager
            rewrite "^news/?" /index.php?main_page=news&% last;
            rewrite "^news/rss.xml" /index.php?main_page=news_rss&% last;
            rewrite "^news/archive/?" /index.php?main_page=news_archive&% last;
            rewrite "^news/([0-9]{4})-([0-9]{2})-([0-9]{2}).html" /index.php?main_page=news&date=$1-$2-$3&% last;
            rewrite "^news/archive/([0-9]{4})-([0-9]{2}).html" /index.php?main_page=news_archive&date=$1-$2&% last;
            rewrite "^news/(.*)-a-([0-9]+)-comments.html" /index.php?main_page=news_comments&article_id=$2&% last;
            rewrite "^news/(.*)-a-([0-9]+).html" /index.php?main_page=news_article&article_id=$2&% last;

            # All other pages
            # Don‘t rewrite real files or directories
            rewrite "^(.*).html" /index.php?main_page=$1&% last;

    VN:F [1.9.14_1148]
    Rating: 0.0/10 (0 votes cast)
    VN:F [1.9.14_1148]
    Rating: 0 (from 0 votes)
    Page 2 of 212