参考:https://blog.csdn.net/u010438035/article/details/104800715
一、环境说明
操作系统:CentOS-6.7-x86_64
内核版本:2.6.32-573.15.3.el6.x86_64
相关服务器:
1 台客户端服务器
1 台LVS均衡服务器
2 台后端Nginx均衡服务器
2 台后端Apache服务器
使用 Oracle VM VirtualBox,四台虚拟机
客户端:192.168.219.4(eth0)
负载均衡:外网VIP=192.168.219.5 (eth0)内网DIP=192.168.56.101(eth1)
后端Nginx 1:192.168.56.105(eth0)
后端Nginx 2:192.168.56.106(eth0)
后端Apache 1:192.168.56.103(eth0)
后端Apache 2:192.168.56.104(eth0)
二、LVS均衡服务器配置
三、Nginx均衡服务器配置
注意:upstream 后面的字符串不能带下划线,否则会报错
Bad Request
Your browser sent a request that this server could not understand.
Additionally, a 400 Bad Request error was encountered while trying to use an ErrorDocument to handle the request.
Apache Server at xxx Port 80
upstream名称中用了”_”,去掉,重启nginx就可以访问了。
四、Apache服务器配置
安装httpd
#yum install -y httpd
启动httpd
#service httpd start
报如下提示:
修改conf配置文件(/etc/httpd/conf/default.conf)
#ServerName 127.0.0.1:80这行把注释去掉就行了,把ip改成你的域名,如果没有域名则改成本机ip。
重启httpd, OK
五、执行测试
在客户端使用curl命令测试