位置 > 首页 > 图说知识 > 科技

nginx负载均衡配置

产品型号: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的数据,转到另外两台服务器上

改:

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服务进行测试负载均衡效果


本站声明:本站部分文章来自网络,由用户上传分享,如若内容侵犯了您的合法权益,可联系我们进行处理。文章仅供大家学习与参考,不**本站立场。

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

相关图片
相关单图
热门图文标签
热门图片标签
热门词条推荐

精美图文推荐

上一篇 下一篇
作者信息
不美〆不萌〆不淑女
(0)赞
2022-07-26 21:20:49
相关专辑
返回首页