首页 > 其他 > 详细

nginx 配置负载均衡器

时间:2016-04-23 13:28:41      阅读:518      评论:0      收藏:0      [点我收藏+]

下面是一段nginx以HTTP形式的反向代理代码

# 编辑nginx.conf文件添加如下代码
upstream http_ziyuan_xueceping_server_pool {
        server 192.168.0.102:92 weight=1 max_fails=2 fail_timeout=60s down;   # 代理到102:92
        server 192.168.0.103:92 weight=1 max_fails=2 fail_timeout=60s;  # 代理到103:92
}


server {
    listen       80;
    server_name  ziyuan.xueceping.cn;
    access_log   logs/www.ziyuan_xueceping93.log main;
    error_log    logs/www.ziyuan_xueceping93_error.log;

    #location / {
    #        # host and port to fastcgi server
    #        #uwsgi_pass 127.0.0.1:6688;  # socket形式
    #        include uwsgi_params;
    #        uwsgi_pass uwsgi_ziyuan_xueceping_server_pool;
    #    }
    location / {
            #proxy_cache cache_one;
            #proxy_cache_valid 200 304 10m;
            #proxy_cache_valid 301 302 1m;
            #proxy_cache_valid any 1m;

            proxy_cache_key $host$uri$is_args$args;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_pass http://http_ziyuan_xueceping_server_pool;   # 设置http代理
            #expires      1d;

   }

}

 

.

 

nginx 配置负载均衡器

原文:http://www.cnblogs.com/weiok/p/5424414.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!