产品型号:Thinkpad E15
系统版本:centos8
安装nginx服务
[root@xuegod63 ~]# yum install -y epel-release
[root@xuegod63 ~]# yum install -y nginx
[root@xuegod63 ~]# vim /etc/nginx/nginx.conf
在server字段外添加配置
upstream htmlservers {
server 192.168.1.62:80;
server 192.168.1.64:80;
}
如图中所示位置:

文章插图
添加反向代理, 将访问192.168.1.63的数据, 转到另外两台服务器上
改:
【nginx负载均衡的三种方式? nginx负载均衡配置】51 location / {
52 }
为:
location / {
proxy_pass http://htmlservers;
}
检查语法
[root@xuegod63 ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
配置xuegod62和xuegod64节点
[root@xuegod62 ~]# yum install -y httpd
[root@xuegod62 ~]# echo "192.168.1.62" > /var/www/html/index.html
[root@xuegod62 ~]# systemctl start httpd
[root@xuegod64 ~]# yum install -y httpd
[root@xuegod64 ~]# echo "192.168.1.64" > /var/www/html/index.html
[root@xuegod64 ~]# systemctl start httpd
访问web服务:http://192.168.1.63/
刷新页面即可看到主机页面 。
总结:
1. 安装nginx服务
2. 配置nginx负载均衡
3. 启动服务器
4. 通过访问web服务进行测试负载均衡效果
- nginx负载均衡配置详解? nginx负载均衡策略
- nginx安装与配置详解? nginx配置文件详解
- 好猫粮的成分构成
- 减脂吃什么主食 主食一定要均衡
- 怎样做才能使全身减肥均衡?
- 如何做到营养均衡生活健康?
- 一杯豆浆、两个韭菜盒子,这样的晚餐可以吗?营养均衡吗?
- cpu负载怎么解决 cpu重负载
- 备孕怀孕食谱-备孕怀孕营养均衡的食谱
- 均衡的饮食可以帮助你减肥的英文 哪种饮食方法可以帮助减肥?
特别声明:本站内容均来自网友提供或互联网,仅供参考,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
