nginx web服务(虚拟主机)、proxy代理、负载均衡

基于端口:

配置文件

 

 

 

  基于IP

基于域名(本地解析记得上传到要访问的服务器上)

负载均衡

三台虚拟机

web-1 web-2  防火墙+selinu网络 yum仓库 安装nginx并运行

web-1:hello web-1   echo "hello web-1" > /usr/share/nginx/html/index.html

web-2:   hello web-2   echo "hello web-2" > /usr/share/nginx/html/index.html

负载均衡(主)

cd /etc/yum.repos.d
vi nginx.repo
yum -y install nginx && systemctl start nginx
systemctl status nginx
cd

vi /etc/nginx/nginx.conf    :添加upstream testapp { 
                                                              server 10.0.105.199:8081;
                                                              server 10.0.105.202:8081;
                                                    }
vi /etc/nginx/conf.d/default.conf  :添加   location / {         
                                                                     proxy_pass  http://testapp;  #请求转向 testapp 定义的服务器列表         
                                                                   } 注释掉location中的两条命令

systemctl restart nginx
 

负载均衡+代理 ()

软件负载均衡、硬件负载均衡、云负载均衡

参数:upstream 地址池   web-sever IP地址

 

 

增加NFS

NFS服务器(192.168.128.186):

安装nfs-utils

mkdir /opt/nfs-data

vi  /etc/exports    添加 /opt/nfs-data *(rw,sync,no_root_squash)

exportfs -rv

unzip jspvz.zip

cp -r jspvz/* /opt/nfs-data

systemctl start nfs

NFS客户端(负载均衡集群)

yum -y install nfs-utils

mkdir /opt/nfs-data

mount -t nfs 192.168.128.186:/opt/nfs-data   /usr/share/nginx/html   //直接挂载到网页发布目录下,浏览器访问

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值