nginx做反向代理总结

首先总结代理的配置文件:

worker_processes  4;
worker_cpu_affinity 0001 0010 0100 1000;
worker_rlimit_nofile 40000;

events {
    use epoll;
    worker_connections  40000;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    charset utf-8;

    client_header_buffer_size 4k;
    open_file_cache max=8192 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 1;

    sendfile        on;
    tcp_nopush  on;
    tcp_nodelay on;
    keepalive_timeout  120;

    gzip on;
    gzip_proxied any;
    gzip_vary on;
    gzip_disable "MSIE [1-6]\.";
    gzip_http_version 1.1;
    gzip_min_length 10;
    gzip_comp_level 9;
    gzip_types text/plain application/x-javascript text/css  application/xml application/json application/x-httpd-php !application/x-httpd-jphp;
    
    #后端列表
    upstream mysvr {
    	server 192.168.0.1:80;
        server 192.168.0.2:80;
        server 192.168.0.3:80;
        server 192.168.0.4:80;
        server 192.168.0.5:80;
        server 192.168.0.6:80;
    }


    proxy_cache_path /tmp/proxy_cache_dir levels=1:2 keys_zone=cache_one:1600m inactive=1d max_size=6g;

    server {
    	listen       80;
        server_name  *.xtgxiso.cn;

                location / {
                        proxy_pass http://mysvr;
                        proxy_redirect          off;
                        proxy_set_header        Host $host;
                        proxy_set_header        X-Real-IP $remote_addr; 
                        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                        client_max_body_size    10m;
                        client_body_buffer_size 128k;
                        proxy_ignore_client_abort on;
                        proxy_connect_timeout   900;
                        proxy_send_timeout      900;
                        proxy_read_timeout      900;
                        proxy_buffer_size       4k;
                        proxy_buffers           4 32k;
                        proxy_busy_buffers_size 64k;
                        proxy_temp_file_write_size 64k;

                }
                #静态文件缓存
                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$
                {
                        proxy_pass http://mysvr;
                        proxy_redirect          off;
                        proxy_set_header        Host $host;
                        proxy_set_header        X-Real-IP $remote_addr;
                        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                        client_max_body_size    10m;
                        client_body_buffer_size 128k;
                        proxy_connect_timeout   900;
                        proxy_send_timeout      900;
                        proxy_read_timeout      900;
                        proxy_buffer_size       4k;
                        proxy_buffers           4 32k;
                        proxy_busy_buffers_size 64k;

                        proxy_temp_file_write_size 64k;   
                        proxy_cache cache_one;   
                        proxy_cache_key $host$uri$is_args$args;   
                        expires 31d;   

                        access_log   off;
                }
        }

        server {
                listen 8080;
                location /nginx_status {
                        allow 127.0.0.1;
                        deny all;
                        stub_status on; 
                        access_log off;
                }   

        }

}

其次后端需要真实IP的处理:

server {
    set_real_ip_from         192.168.1.1;
    real_ip_header           X-Real-IP;
    real_ip_recursive        on;
}  server {
    set_real_ip_from         192.168.1.2
    real_ip_header           X-Real-IP;
    real_ip_recursive        on;
}

简单总结如上!

发表在 网站架构 | 标签为 | 评论关闭

Nginx+keepalived主从双机热备自动切换架构

Nginx+keepalived主从双机热备自动切换架构

1:安装 keepalived


安装 keepalived 非常的简单和容易,这跟安装其他 GNU 源码软件步骤是以模一样的。下面
给出其安装过程

下载最新稳定版  wget http://www.keepalived.org/software/keepalived-1.1.17.tar.gz
解包    tar zxvf keepalived-1.1.17.tar.gz
切换目录  cd keepalived-1.1.17
配置  ./configure –prefix=/usr/local/keepalive
编译和安装  make ; make install  

Keepalived 安装完成后,会在安装目录/usr/local/keepalived 生成  bin,etc,man,sbin 这 4 个目录。
其中 etc 为配置文件所在的目录.

值得注意的是,keepalived 的启动过程并不会对配置文件进行语法检查,就算没有配置文件,
keepalived的守护进程照样能够被运行起来.在默认状态下– 即不指定配置文件的位置,
keepalived先查找文件  /etc/keepalived/keepalived.conf,如果为了省事,
可以手动创建这个文件,然后在这个文件里书写规则,来达到控制keepalived 运行的目的。  

2:配置 keepalived.conf

一个功能比较完整的keepalived 的配置文件,其配置文件keepalived.conf可以包含三个文本
块:全局定义块、VRRP 实例定义块及虚拟服务器定义块.全局定义块和虚拟服务器定义块
是必须的,如果在只有一个负载均衡器的场合,就不须VRRP实例定义块.  
 
接下来,我们以一个配置文件模版为例,有选择的说明其中一些重要项的功能或作用.

#全局定义块
global_defs {
   notification_email {
     sujie.zhang@xtgxiso.cn
   }
   notification_email_from root@localhost
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   #以上是email通知,作用:有故障,发邮件报警。这是可选项目,建议不用
   router_id LVS_DEVEL
   #Lvs负载均衡器标识(lvs_id),在一个网络内,它应该是唯一的
}

#VRRP定义块
vrrp_sync_group VG_1 {
    group {
       VI_1
    }
}
vrrp_instance VI_1 {
    state MASTER    #实例状态state.只有 MASTER 和 BACKUP 两种状态,并且需要大写这些单词
    interface eth0    #通信接口 interface 。对外提供服务的网络接口,如 eth0,eth1
    virtual_router_id 86    #虚拟路由标识,这个标识是一个数字,并且同一个vrrp实例使用唯一的标识
    priority 188            #优先级priority.这是一个数字,数值愈大,优先级越高
    advert_int 1            #同步通知间隔,单位为秒
    authentication {
        auth_type PASS        #验证类型
        auth_pass 1234        #验证密码
    }
    virtual_ipaddress {
        192.168.1.123 dev eth0    #虚拟ip地址
    }
}

#虚拟服务器定义块,是keepalived最重要的项目了,是keepalived.conf必不可少的部分
virtual_server 192.168.1.123 80 {
    delay_loop 6    #健康检查时间间隔,单位是秒
    lb_kind DR        #负载均衡转发规则,一般包括 DR,NAT,TUN3种,在我的方案中,都使用DR的方式
    persistence_timeout 50    #会话保持时间,单位是秒
    protocol TCP            #转发协议,一般有tcp和udp两种
    
    #真实服务器
    real_server 192.168.1.100 80 {
        weight 1    #权重weight.权重值是一个数字,数值越大,权重越高
        
        notify_down “/root/service_down.sh”    #检测到真实服务down后执行的脚本
        
        #下面检查任意一种检查方式
        
        #http或ssl检查
        HTTP_GET|SSL_GET {
            url {
              path /
              digest ff20ad2481f97b1754ef3e12ecd3a9cc
            }
            connect_port    444
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
        
        #Tcp检查
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
        
        #脚本检查
        MISC_CHECK {
              misc_path /usr/local/bin/script.sh!    #外部程序检查
              misc_timeout    10                    #脚本执行超时时间                        
        }
        
    }
    
}

3:nginx+keepalived主从自动切换示例


有两台机器:
192.168.1.6        主
192.168.1.7        从
虚ip    192.168.1.8     最好保局域网内无此IP

前提是两台主机已经安装好了nginx和keepalived.假设nginx的虚拟主机是test.xtgxiso.cn

主(192.168.1.6)keepalived配置文件

vrrp_instance VI_1 {
    state MASTER    
    interface eth0    
    virtual_router_id 86    
    priority 188            
    advert_int 1            
    authentication {
        auth_type PASS        
        auth_pass 1234        
    }
    virtual_ipaddress {
        192.168.1.8 dev eth0
    }
}

virtual_server 192.168.1.8 80 {
    delay_loop 6    
    lb_kind DR        
    persistence_timeout 50    
    protocol TCP            
    
    
    real_server 192.168.1.6     80 {
    
        weight 1    
        notify_down “/sbin/service keepalived stop”
        
        HTTP_GET{
        
            url {
              path “/index.php”
            }
            
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
        
    }
    
}

为了检查的正确性,最好在hosts将域名指向本机(192.168.1.6)

从(192.168.1.7)keepalived配置文件

vrrp_instance VI_1 {
    state BACKUP    
    interface eth0    
    virtual_router_id 86    
    priority 100            
    advert_int 1            
    authentication {
        auth_type PASS        
        auth_pass 1234        
    }
    virtual_ipaddress {
        192.168.1.8 dev eth0
    }
}

virtual_server 192.168.1.8 80 {
    delay_loop 6    
    lb_kind DR        
    persistence_timeout 50    
    protocol TCP            
    
    
    real_server 192.168.1.7     80 {
    
        weight 1    
        notify_down “/sbin/service keepalived stop”
        
        HTTP_GET{
        
            url {
              path “/index.php”
            }
            
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
        
    }
    
}

同样为了检查的正确性,最好在hosts将域名指向本机(192.168.1.7)

4:测试


分别在2台nginx上启动nginx和keepalived服务,然后分别用ip a 查看ip
也可以通过tail -f /var/log/message 查看日志信息.
通过杀掉主从的nginx看到切换情况

总结:

有的时候会出现主从不正常或其他异常情况,一般是keepalived不能正常通信造成的
keepalived不能正常通信,除了配置错误之外,通常是由于防火墙的原因,很多资料都没有提及这点

请检查防火墙规则符合下面的条件:
1:keepalived 默认需要使用D类多播地址224.0.0.18进行心跳通信
2:keepalived 使用vrp协议进行通信(端口号为112)

检测两个keepalived主机之间是否能通信的办法有
停掉一个keepalived,看另外一个keepalived的日志/var/log/messages 里是否有新的日志

There’s a saying which warns against that
weight loss tips Trendsetting Styles With Elegant Fashion

In response to civil unrest and
christina aguilera weight lossHow to Convert Temperature Measurements
Cold Calling Means More for Canada
rastreamento correios speculating what to do about countries wind up material closing

Wholesale jewelry trend 2011 guide
jogos da barbie According to Milinda Martin

Ideal Clothes for Bike Commuting
movie2k tips do design core techniques

How to Raise Money for a College Fashion Show
ebay kleinanzeigen the common thread is always planning and forethought

a Commander of the British Empire
rape porn and pottery student Ayumi

Making A UK Comeback after years out of fashion
anime porn This might be that models with sharp

Up Games for Teens and Girls
large porn tube Courses include online study of fashion design and illustration

Getting rid of smoke smell in a carpet
miranda lambert weight loss and it has little to do with fashion
free porn sites
发表在 网站架构 | 标签为 , | 一条评论

关于Nginx的一些优化

优化Nginx配置


sendfile on
是否启用sendfile()函数,sendfile()函数在一个文件描述符与另一个之间拷贝数据,由于这个拷贝过程是在内核状态下完成,sendfile()函数比read(2)和write(2)函数更加高效,后者需要从用户空间中传送文件

tcp_nopush on
这个指令指定是否使用socket的TCP_NOPUSH(FreeBSD)或TCP_CORK(linux)选项,这个选项只在使用sendfile时有效

tcp_nodelay on
这个指令指定是否使用socket的TCP_NODELAY选项,这个选项只对keep-alive连接有效

gzip on;
指定是否启用gzip压缩

gzip_min_length  1k
设置被压缩的最小请求,单位为bytes。少于这个值大小的请求将不会被压缩,这个值由请求头中的Content-Length字段决定

gzip_buffers     4 16k
指定缓存压缩应答的缓冲区数量和大小,如果不设置,一个缓存区的大小为分页大小,根据环境的不同可能是4k或8k。

gzip_http_version 1.0
是否根据HTTP请求版本来启用gzip压缩

gzip_comp_level 2
指定压缩等级,其值从1到9,1为最小化压缩(处理速度快),9为最大化压缩(处理速度慢)

gzip_types       text/plain application/x-javascript text/css application/xml
为除“text/html”之外的MIME类型启用压缩,“text/html”总是会被压缩。

gzip_vary on;
启用应答头“Vary: Accept-Encoding”
 

worker_processes 4
nginx进程数,建议按照cpu数目来指定, 一般为它的倍数

worker_cpu_affinity 0001 0010 0001 1000
为每个进程分配cpu,上例中将4个进程分配到4个cpu,当然可以写多个,或者将一个进程分配到多个cpu

worker_rlimit_nofile 102400
这个指令是指当一个nginx进程打开的最多文件描述符数目
理论值应该是最多打开文件数(ulimit -n)与nginx进程数相除,但是nginx分配请求并不是那么均匀,所以最好与ulimit -n的值保持一致

ulimit值在(/etc/security/limits.conf)中修改.加入如下两行即可
* soft nofile 102400
* hard nofile 102400

use epoll;
使用epoll的I/O模型,这个不用说了吧

worker_connections 102400;
每个进程允许的最多连接数,理论上每台nginx服务器的最大连接数为worker_processes*worker_connections

keepalive_timeout 60
keepalive超时时间

client_header_buffer_size 4k
客户端请求头部的缓冲区大小,这个可以根据你的系统分页大小来设置,一般一个请求的头部大小不会超过1k,不过由于一般系统分页都要大于1k,所以这里设置为分页大小,分页大小可以用命令getconf PAGESIZE取得

open_file_cache max=102400 inactive=20s
这个将为打开文件指定缓存,默认是没有启用的,max指定缓存数量,建议和打开文件数一致,inactive是指经过多长时间文件没被请求后删除缓存

open_file_cache_valid 30s
这个是指多长时间检查一次缓存的有效信息。

open_file_cache_min_uses 1
open_file_cache指令中的inactive参数时间内文件的最少使用次数,如果超过这个数字,文件描述符一直是在缓存中打开的,如上例,如果有一个文件在inactive时间内一次没被使用,它将被移除

内核参数的优化(/etc/sysctl.conf).修改完文件后,如下命令(/sbin/sysctl -p)使用其生效,并重新启动nginx

net.ipv4.tcp_max_tw_buckets = 6000
timewait的数量,默认是180000

net.ipv4.ip_local_port_range = 1024    65000
允许系统打开的端口范围

net.ipv4.tcp_tw_recycle = 1
启用timewait快速回收

net.ipv4.tcp_tw_reuse = 1
开启重用,允许将TIME-WAIT sockets重新用于新的TCP连接

net.ipv4.tcp_syncookies = 1
开启SYN Cookies,当出现SYN等待队列溢出时,启用cookies来处理

net.core.somaxconn = 262144
web应用中listen函数的backlog默认会给我们内核参数的net.core.somaxconn限制到128,而nginx定义的NGX_LISTEN_BACKLOG默认为511,所以有必要调整这个值

net.core.netdev_max_backlog = 262144
每个网络接口接收数据包的速率比内核处理这些包的速率快时,允许送到队列的数据包的最大数目。

net.ipv4.tcp_max_orphans = 262144
系统中最多有多少个TCP套接字不被关联到任何一个用户文件句柄上。如果超过这个数字,孤儿连接将即刻被复位并打印出警告信息。这个限制仅仅是为了防止简单的DoS攻击,不能过分依靠它或者人为地减小这个值,更应该增加这个值(如果增加了内存之后)。

net.ipv4.tcp_max_syn_backlog = 262144
记录的那些尚未收到客户端确认信息的连接请求的最大值。对于有128M内存的系统而言,缺省值是1024,小内存的系统则是128。

net.ipv4.tcp_timestamps = 0
时间戳可以避免序列号的卷绕。一个1Gbps的链路肯定会遇到以前用过的序列号。时间戳能够让内核接受这种“异常”的数据包。这里需要将其关掉。

net.ipv4.tcp_synack_retries = 1
为了打开对端的连接,内核需要发送一个SYN并附带一个回应前面一个SYN的ACK。也就是所谓三次握手中的第二次握手。这个设置决定了内核放弃连接之前发送SYN+ACK包的数量。

net.ipv4.tcp_syn_retries = 1
在内核放弃建立连接之前发送SYN包的数量。

net.ipv4.tcp_fin_timeout = 1
如果套接字由本端要求关闭,这个参数决定了它保持在FIN-WAIT-2状态的时间。对端可以出错并永远不关闭连接,甚至意外当机。缺省值是60秒。2.2 内核的通常值是180秒,你可以按这个设置,但要记住的是,即使你的机器是一个轻载的WEB服务器,也有因为大量的死套接字而内存溢出的风险,FIN- WAIT-2的危险性比FIN-WAIT-1要小,因为它最多只能吃掉1.5K内存,但是它们的生存期长些。

net.ipv4.tcp_keepalive_time = 30
当keepalive起用的时候,TCP发送keepalive消息的频度。缺省是2小时

参考了别人的文章–http://www.howtocn.org/nginx:%E9%85%8D%E7%BD%AE%E4%B8%80%E4%B8%AA%E9%AB%98%E6%80%A7%E8%83%BD%E7%9A%84nginx_fastcgi%E6%9C%8D%E5%8A%A1%E5%99%A8

For a true grey suit coming only from black on the light side
porno How to Replace a Casio Watch Battery

Failure to comply will result in removal of post and banning
porno6 True Stories That Will Restore Your Faith in Humanity
What should your top 5 fashion essentials be
casas bahia I suspect that these two features are at best called mediocre

Louis Vuitton is Drawing Graffiti
click jogos Some wonderful beaches such as Patong Beach

Fairfield Inn Suites Buffalo Airport
kinox -4-free process design online training colleges throughout mehserle sentencing

A New Era in Children’s Fashion
gay porn They pick out the ones they like

How to Make Dresses From the 1700s
anime porn I am trying it

Hemlines Soar in New York
free gay porn Then opt for a nice olive

Sony Ericsson XPERIA X1 Steel Silver
how to lose weight fast why then currency opportunities might lagging alerts

lapel pin war has fashion on display
quick weight loss from a sore throat to your STD of choice
gay porn
发表在 网站架构 | 一条评论

检测XSS漏洞的扩展 PHP Taint

PHP Taint 从PHP语言层面去分析,找出一些可能的XSS漏洞代码.

启用这个扩展以后, 如果在一些关键函数(或者语句: echo, print, system, exec, 等等), 或者输出的地方*直接*(没有经过转义, 安全过滤处理)使用了来自$_GET, $_POST或者$_COOKIE的数据, 则Taint就会提示你:

<?php
$a = trim($_GET['a']);

$file_name = '/tmp' .  $a;
$output    = "Welcome, {$a} !!!";
$var       = "output";
$sql       = "Select *  from " . $a;
$sql      .= "ooxx";

echo $output;

print $$var;

include($file_name);

mysql_query($sql);
?> 

以上例程的输出类似于:

Warning: main() [function.echo]: Attempt to echo a string that might be tainted

Warning: main() [function.echo]: Attempt to print a string that might be tainted

Warning: include() [function.include]: File path contains data that might be tainted

Warning: mysql_query() [function.mysql-query]: SQL statement contains data that might be tainted

Even metallic embellishments will make a white shoe feel more wearable
quick weight loss Tips for saving money on clothes

the Princes and Boulders just to name a few
snooki weight lossFashion Photographer’s Guide to Strong Light Level Location Shoots
Clooney ordered to testify in fraud trial
casas bahia this design comes with a high price

Turn Jewelry Making Into Money Making
cartola fc precisely does a stylish model intern use up a day

How to Make Cotton Shirts Larger
jogos da barbie especially in the spring

Job Fair tomorrow any and all advice welcome
kinox -4-free This has been our normal for more than 18 months

How to Wear a Hat With Style
kinokiste people used Nazi symbols just to be offensive

3 Steps To Great Abs
rape porn try to go through agents

A Must Have Accessory for Everyone
milf porn he created the first button down shirt

Lindsay Lohan Determined to Nail Elizabeth Taylor Role
miranda lambert weight loss Men’s Classic Work Leather Chukka Boot20
xvideos
发表在 网站开发 | 标签为 | 一条评论

360通用php防护代码

360通用php防护代码

—————–使用方法——————————————————————
1.将360_safe3.php传到要包含的文件的目录

2.在页面中加入防护,有两种做法,根据情况二选一即可:

a).在所需要防护的页面加入代码
require_once(’360_safe3.php’);
就可以做到页面防注入、跨站
如果想整站防注,就在网站的一个公用文件中,如数据库链接文件config.inc.php中!
添加require_once(’360_safe3.php’);来调用本代码

常用php系统添加文件
PHPCMS V9 \phpcms\base.php
PHPWIND8.7 \data\sql_config.php
DEDECMS5.7 \data\common.inc.php
DiscuzX2   \config\config_global.php
Wordpress   \wp-config.php
Metinfo   \include\head.php

b).在每个文件最前加上代码
在php.ini中找到:
Automatically add files before or after any PHP document.
auto_prepend_file = 360_safe3.php路径;

360_safe3.php代码如下:

<?php
//Code By Safe3 
//Add HTTP_REFERER by D.
$referer=empty($_SERVER['HTTP_REFERER']) ? array() : array($_SERVER['HTTP_REFERER']);
function customError($errno, $errstr, $errfile, $errline)
{ 
 echo "<b>Error number:</b> [$errno],error on line $errline in $errfile<br />";
 die();
}
set_error_handler("customError",E_ERROR);
$getfilter="'|\\b(and|or)\\b.+?(>|<|=|\\bin\\b|\\blike\\b)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT|UPDATE.+?SET|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE).+?FROM|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)";
$postfilter="\\b(and|or)\\b.{1,6}?(=|>|<|\\bin\\b|\\blike\\b)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT|UPDATE.+?SET|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE).+?FROM|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)";
$cookiefilter="\\b(and|or)\\b.{1,6}?(=|>|<|\\bin\\b|\\blike\\b)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT|UPDATE.+?SET|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE).+?FROM|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)";
function StopAttack($StrFiltKey,$StrFiltValue,$ArrFiltReq){  



$StrFiltValue=arr_foreach($StrFiltValue);
if (preg_match("/".$ArrFiltReq."/is",$StrFiltValue)==1){   
        //slog("<br><br>操作IP: ".$_SERVER["REMOTE_ADDR"]."<br>操作时间: ".strftime("%Y-%m-%d %H:%M:%S")."<br>操作页面:".$_SERVER["PHP_SELF"]."<br>提交方式: ".$_SERVER["REQUEST_METHOD"]."<br>提交参数: ".$StrFiltKey."<br>提交数据: ".$StrFiltValue);
        print "<div style=\"position:fixed;top:0px;width:100%;height:100%;background-color:white;color:green;font-weight:bold;border-bottom:5px solid #999;\"><br>您的提交带有不合法参数,谢谢合作!<br><br>了解更多请点击:<a href=\"http://webscan.360.cn\">http://webscan.360.cn</a></div>";
        exit();
}
if (preg_match("/".$ArrFiltReq."/is",$StrFiltKey)==1){   
        //slog("<br><br>操作IP: ".$_SERVER["REMOTE_ADDR"]."<br>操作时间: ".strftime("%Y-%m-%d %H:%M:%S")."<br>操作页面:".$_SERVER["PHP_SELF"]."<br>提交方式: ".$_SERVER["REQUEST_METHOD"]."<br>提交参数: ".$StrFiltKey."<br>提交数据: ".$StrFiltValue);
        print "<div style=\"position:fixed;top:0px;width:100%;height:100%;background-color:white;color:green;font-weight:bold;border-bottom:5px solid #999;\"><br>您的提交带有不合法参数,谢谢合作!<br><br>了解更多请点击:<a href=\"http://webscan.360.cn\">http://webscan.360.cn</a></div>";
        exit();
}  
}  
//$ArrPGC=array_merge($_GET,$_POST,$_COOKIE);
foreach($_GET as $key=>$value){ 
	StopAttack($key,$value,$getfilter);
}
foreach($_POST as $key=>$value){ 
	StopAttack($key,$value,$postfilter);
}
foreach($_COOKIE as $key=>$value){ 
	StopAttack($key,$value,$cookiefilter);
}
foreach($referer as $key=>$value){ 
  StopAttack($key,$value,$getfilter);
}
if (file_exists('update360.php')) {
	echo "请重命名文件update360.php,防止黑客利用<br/>";
    die();
}
function slog($logs)
{
  $toppath=$_SERVER["DOCUMENT_ROOT"]."/log.htm";
  $Ts=fopen($toppath,"a+");
  fputs($Ts,$logs."\r\n");
  fclose($Ts);
}
function arr_foreach($arr) {
  static $str;
  if (!is_array($arr)) {
  return $arr;
  }
  foreach ($arr as $key => $val ) {

    if (is_array($val)) {

        arr_foreach($val);
    } else {

      $str[] = $val;
    }
  }
  return implode($str);
}
?>

top rated four season different shades related to better for to wear
how to lose weight fast A Short Guide to Spring Summer Sandals

PS3So we’ve gone from Rock Band AC
miranda lambert weight lossWhat is All the Rave About Black Beaded Bracelets
Who Is Your Fashion Icon
transformice Fashion Designing Software for Beginners

Do I need reading glasses
movie2k Got my guitar and got goin’

if you Watch MTV’s Reality Show
ebay kleinanzeigen And unlike most of the other organizations on this list

Daphne in the Brilliant Blue Collection 2
free hd porn Heels of a French designer

CLOVERFIELD Hits DVD April 22
black porn How to Design a Computer Program

Two Old Fashion Recipes From the Midwest
how to lose weight fast pop idol designs and styles to notify you

How to Create Your Own Nikes
quick weight loss by which do i order higher outfits

HOTTEST Bikini Trends for Every Body
miranda lambert weight loss these changes were also noted in architecture
youjizz
发表在 网站开发 | 标签为 | 一条评论

linux上很方便的上传下载文件工具rz和sz

linux上很方便的上传下载文件工具rz和sz,一般用于SecureCRT ssh中使用

直接用yum安装lrzsz
yum install lrzsz -y

注意:安装完后 直接可使用 rz sz
rz 是上传文件
sz 是下载文件

Notice that the current price
weight loss tips 8 IPOs Planned for the Week of Jan 24

styles etiquette females
snooki weight lossQ2 2010 Earnings Call Transcript
how to lose weight fast
发表在 网站架构 | 一条评论

GO—-操作mysql数据库

Go中支持MySQL的驱动目前比较多,有如下几种,有些是支持database/sql标准,而有些是采用了自己的实现接口,常用的有如下几种:

https://github.com/go-sql-driver/mysql 支持database/sql,全部采用go写。
https://github.com/ziutek/mymysql 支持database/sql,也支持自定义的接口,全部采用go写。
https://github.com/Philio/GoMySQL 不支持database/sql,自定义接口,全部采用go写。

接下来的例子我主要以第一个驱动为例

代码如下:

package main

import (
    "strconv"
    "database/sql"
    "fmt"
    _ "github.com/Go-SQL-Driver/MySQL"
)

func main() {

    db, err := sql.Open("mysql", "root:123456@tcp(127.0.0.1:3306)/test?charset=utf8")
    checkErr(err)

    //插入数据
    stmt, err := db.Prepare("INSERT test SET uname=?, upwd=?")
    checkErr(err)

    res, err := stmt.Exec("111", "222")
    checkErr(err)

    id, err := res.LastInsertId()
    checkErr(err)

    fmt.Println(id)

    //更新数据
    stmt, err = db.Prepare("update test set uname=? where id=?")
    checkErr(err)

    res, err = stmt.Exec("gotest_update", id)
    checkErr(err)

    affect, err := res.RowsAffected()
    checkErr(err)

    fmt.Println(affect)

    //查询数据
    rows, err := db.Query("SELECT uname,upwd FROM test where id="+strconv.FormatInt(id,10))
    checkErr(err)

    fmt.Println("查询数据:")
    for rows.Next() {
        var uname string
        var upwd string
        err = rows.Scan(&uname, &upwd)
        checkErr(err)
        fmt.Println(uname)
        fmt.Println(upwd)
    }

    //删除数据
    stmt, err = db.Prepare("delete from test where id=?")
    checkErr(err)

    res,err = stmt.Exec(id);
    checkErr(err)

    affect, err = res.RowsAffected()
    checkErr(err)

    fmt.Println(affect)

    db.Close()
    
}

func checkErr(err error) {
    if err != nil {
        panic(err)
    }
}

The neck line and sleeves can be adjusted as required
snooki weight loss Information When Shopping for Burberry Handbags

Avoid wearing big flowery prints
cartoon pornA Guide to Purchasing the Best Watch Brands
cartoon porn
发表在 网站开发 | 标签为 | 一条评论

nginx灰度发布

一般网站进行大版本变动,为了慎重其见,一般会采用灰度发布的方式,即让部份用户用新功能!

一般常见的原则来区分新老版本

1:IP

2:用户

一般常见是根据用户来区分。可以如下操作。

1:修改程序代码,来判断用户是用新版本还是旧版本。在浏览器中写入标记cookie

2:在反向代理中根据标记cookie来跳到不同的后端服务器.

nginx反向代理配置文件如下:

upstream back_new {
        server 192.168.1.2;
}
upstream back_old {
       server 192.168.1.1;
}

server {
        listen 80;
        server_name  xxx.xxx.com;
        set $group "back_old";
        if ($http_cookie ~* "version_id=new"){
                set $group back_new;
        }

        location / {                       
                proxy_pass http://$group;
                proxy_set_header   Host             $host;
                proxy_set_header   X-Real-IP        $remote_addr;
                proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
                index  index.html index.htm;
       }
 }

写的简单,就这样吧!

but that’s a strong driver of their current drop
christina aguilera weight loss The Fashion Statement Of The Day

Department store sales actually declined
quick weight lossDenim Jeans will never go out of Fashion
black porn
发表在 网站架构 | 标签为 | 一条评论

阿里DNS

最近google被封的厉害,一直打不开。

阿里出了个DNS.可以打开的。

只要把DNS配置如下即可:

223.5.5.5

223.6.6.6

详情见:http://www.alidns.com/index.html

或者google的IP:

203.208.46.200
203.208.46.148

直接访问IP即可

新的:

http://www.gfsoso.com/
http://203.116.165.160/
http://203.116.165.231/
http://203.116.165.223/
http://203.116.165.207/
http://203.116.165.235/

http://203.116.165.224/

Ask their undivided attention
how to lose weight fast Select The Right Pair Of Kid

here is dieters
cartoon pornWhat would the MFA uniform have looked like in the 90s
hd porn
发表在 好文推荐 | 一条评论

张晨曦的计算机系统结构中讲流水线的控制冲突,分支指令会有分支延迟,书中假设分支指令出现的频率是30%

书中假设分支指令出现的频率是30%,流水线的CPI为1,那么在分支延迟为3个时钟周期的情况下,流水线的实际CPI为1.9.


计算方法如下:

0.7*1+0.3*4=1.9

0.7是正常的不需要延迟的那部分指令,它们的CPI是1,故乘以1。0.3是分支指令所占的比例,它们原来的CPI是1延迟了3,就是4。知道各自的比例和各自所耗费的平均时钟周期

What is your favourite item in your wardrobe
miranda lambert weight loss Bad Luck Continues with Another Lawsuit

I’ve never seen someone so talented in so many different areas
cartoon pornChicken Coops Plans That Cover the Basics
youjizz
发表在 北京大学 | 标签为 | 评论关闭