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

利用nginx做负载均衡

2015-08-12 10:37 555 查看
round-robin:轮询。以轮询方式将请求分配到不同服务器上,默认

least-connected:最少连接数。将下一个请求分配到连接数最少的那台服务器上

ip-hash :基于客户端的IP地址。散列函数被用于确定下一个请求分配到哪台服务器上

nginx.conf

upstream myapp {
#least_conn;
#ip_hash;
#server 192.168.10.29:80 weight=3; #值越大权重就越大
server 192.168.10.29:80;
server 192.168.10.29:8090;
}

server {
listen       8080;
server_name  localhost;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {
proxy_pass        http://myapp; proxy_set_header   Host             $host;
proxy_set_header   X-Real-IP        $remote_addr;
proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
#root   html;
#root   /Users/zhoutingze/vhost/8080;
#index  index.html index.htm index.php;
#rewrite ^(.*)$ index.php/$1;
#rewrite (.*) /index.php;
}


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