nginx负载均衡配置
2016-12-26 18:08
169 查看
nginx负载均衡
一、nginx安装
详见:http://blog.csdn.net/zhengyong15984285623/article/details/53871752二、负载均衡机制
least_conn、ip_hash;在nginx中支持以下负载均衡机制:
轮询 - 向应用服务器的请求以循环方式分布,
最小连接 - 下一个请求分配给具有最少活动连接数的服务器,
ip-hash - 散列函数用于确定应为下一个请求选择什么服务器(基于客户端的IP地址)。
三、负载均衡示例
轮询方式(默认):http { upstream myapp1 { server srv1.example.com max_fails=3 fail_timeout=30s; server srv2.example.com; server srv3.example.com; } server { listen 80; server_name localhost; location / { proxy_pass http://myapp1; } } }
最小连接:
upstream myapp1 { least_conn server srv1.example.com; server srv2.example.com; server srv3.example.com; }
hash方式:
upstream myapp1 { ip_hash; server srv1.example.com; server srv2.example.com; server srv3.example.com; }
权重方式:
upstream myapp1 { server srv1.example.com weight=3; server srv2.example.com; server srv3.example.com; }
四、参考文档
参考文档地址:http://nginx.org/en/docs/http/load_balancing.html#nginx_load_balancing_configuration相关文章推荐
- 6 Nginx负载均衡和反向代理配置
- Nginx负载均衡如何进行配置
- Nginx负载均衡配置实例详解
- Nginx负载均衡与反向代理的配置实例
- nginx负载均衡配置
- Nginx负载均衡与反向代理的配置实例
- Nginx负载均衡配置实例详解
- nginx负载均衡配置
- 5种nginx负载均衡配置方法分享
- Nginx负载均衡如何进行配置
- 简单的nginx负载均衡配置
- Nginx负载均衡配置
- web架构 之 Nginx负载均衡 负载策略配置
- Nginx负载均衡配置实例详解
- Nginx负载均衡如何进行配置
- nginx负载均衡与反向代理配置文件分析实例
- nginx负载均衡配置
- Nginx负载均衡配置实例详解
- nginx负载均衡篇二、nginx配置
- Nginx负载均衡配置实例详解