nginx 负载平衡 load balance 应用
继 nginx 代理伺服器做完不同主机 ip、网址的转向功能后,nginx 另一个功能就是负载平衡应用,本次实作的环境如下:
nginx server 192.168.1.211
作业系统CentOS 6.6
apache server1 192.168.1.212
作业系统 Centos 6.6 + xampp
apache server2 192.168.1.214
作业系统 ubuntu14.04 LTS
用户端 192.168.1.213
作业系统 windows 7
修改 nginx 设定档
vi /etc/nginx/conf.d/default.conf
upstream anthony.com {
server 192.168.1.212 weight=1; #负载平衡分流的主机1,权重1
server 192.168.1.214 weight=2; #负载平衡分流的主机2,权重2
}
server {
listen 80;
server_name anthony.com;
access_log /var/log/nginx/nginx_access_log;
error_log /var/log/nginx/localhost-error.log;
location / {
#proxy_pass_header Server;
#proxy_redirect off;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Scheme $scheme;
proxy_pass http://anthony.com;
}
}
存档
在用户端本机hosts修改设定
192.168.1.211 http://anthony.com
开启浏览器 http://anthony.com

按下重新整理

完成!!
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)

我反复看了多遍,好文,得支持