您的位置:首页 > 运维架构 > Nginx

Nginx 负载均衡 设置

2015-11-18 14:32 633 查看
Nginx做代理服务器,实现负载均衡配置:

nginx.conf

#user  nobody;

worker_processes  1; 

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

 

#pid        logs/nginx.pid;

 

events {

    worker_connections  10000;

}

 

http {

    include       mime.types;

    default_type  application/octet-stream;  

    sendfile        on;

  

    keepalive_timeout  65; 

 

   #设置被负载均衡的服务器路径  weight权重

    upstream site { 

       server  127.0.0.1:80         weight=2; 

       server  127.0.0.1:8080       weight=2; 

       #server   192.168.100.4:8091 weight=2; 

    } 


    server {

        listen       8079;

        server_name  localhost; 

        location / {

             proxy_pass         http://site;    # 代理

             root html;

             index index.html index.htm;

        } 


 

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        } 

    }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nginx 负载均衡