标签:
配置说明
down :           当前的IP server暂时不参与负载,不进行反向代理
weight:          默认为1,weight越大,负载的权重越大
max_fails:       允许请求失败的次数默认为1,当超过最大次数时,返回proxy_next_upstream模块定义的错误
fail_timeout :   max_fails 次失败后,暂停的时间
backup:          不参与负载 当其他负载服务忙或挂掉时请求backup服务器 
配置如下
upstream myCluster { 
    server 115.29.34.154 weight=1 max_fails=2 fail_timeout=5s down;
    server 202.199.158.1 weight=1 max_fails=2 fail_timeout=5s backup;
    server 192.168.1.15 weight=1 max_fails=2 fail_timeout=5s;
}
    
    
    server {
    
        # 监听的端口
        listen    80;
        
        # 主机名称
        server_name  www.abc.com;
        
        # 网站根目录
        root    "G:\WNMPSVR\wwwroot\default\abc";
        
        # 错误日志路径
        error_log    "G:\WNMPSVR\wwwroot\default\abc\error.log";
        
        # 访问日志路径
        access_log    "G:\WNMPSVR\wwwroot\default\abc\access.log";
        
        
        # 根目录相关设置
        location /{
            
            index index.html;
            autoindex    off;
            error_page 404 = 404.html; 
            
            proxy_pass http://myCluster ; #这里的名字和上面的cluster的名字相同 
            proxy_buffering off;
        } 
        
            
    }
标签:
原文地址:http://www.cnblogs.com/thinkxmg/p/4679778.html