实验环境
主机名 | ip | 服务 |
---|---|---|
nginx | 192.168.174.111 | nginx |
httpd | 192.168.174.222 | httpd |
httpd1 | 192.168.174.150 | httpd |
负载均衡步骤
- 搭建服务完成相应配置,关闭防火墙
- 在目标服务器上搭建网站用来测试效果
[root@httpd html]# echo '222 hello' > index.html
[root@httpd1 html]# echo '150 huhu'> index.html
开启服务
- 在nginx主机上修改配置文件
[root@nginx ~]# vim /usr/local/nginx/conf/nginx.conf
upstream webservers {
server 192.168.174.222;
server 192.168.174.150;
}
server {
listen 80;
se