haproxy 代理

准备环境

       三台服务员 一台做haproxy 代理

       12.18.130.138 做nginx 页面发布服务器

       12.18.130.139 做nginx 页面发布服务器

       12.18.130.137  做haproxy 代理

一、nginx 1 部署配置haproxy代理页面(rs1)

1、部署web服务

#  yum -y install nginx 


1.1 修改nginx1    12.18.130.139   配置文件配置页面

# vim /etc/nginx/conf.d/default.conf

server {
   listen 80;
   server_name _;

   location / {
      root /wed/xxy;
     index  index.html index.htm;

  }

}

1.2 创建发布目录

# mkdir -pv /wed/xxy

1.3 写发布目录内容

# vim /wed/xxy/index.html

1.4 重启nginx

# systemctl restart nginx

二、在nginx2上部署haproxy代理页面 (rs2)


1、部署web服务

#  yum -y install nginx 


1.1 修改nginx1    12.18.130.138  配置文件配置页面

# vim /etc/nginx/conf.d/default.conf

server {
   listen 80;
   server_name _;

   location / {
      root /wed/xxy;
     index  index.html index.htm;

  }

}

1.2 创建发布目录

# mkdir -pv /wed/xxy

1.3 写发布目录内容

# vim /wed/xxy/index.html

1.4 重启nginx

# systemctl restart nginx
 

三、配置haproxy  代理服务器

12.18.130.137  做haproxy 代理

1、安装haproxy

# yum install haproxy -y

2、修改配置haproxy
# cp  /etc/haproxy/haproxy.cfg  /etc/haproxy/haproxy.cfg.bak

# vim  /etc/haproxy/haproxy.cfg

# cat /etc/haproxy/haproxy.cfg
global
    log                     127.0.0.1 local2
    chroot                  /var/lib/haproxy
    pidfile                 /var/run/haproxy.pid
    maxconn                 4000
    user                    haproxy
    group                   haproxy
    daemon        

defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s

listen stats
    bind                        *:1314
    stats                       enable
    stats refresh         30s
    stats                       hide-version
    stats uri                  /stats
    stats realm             Haproxy\ stats
    stats auth               kunkun:year2.5
    stats admin                 if TRUE

frontend web
    mode               http
    bind               *:80
    default_backend    httpservers

backend httpservers
    balance roundrobin
    server http1 12.18.130.139:80 maxconn 2000 weight 1  check inter 1s rise 2 fall 2
    server http2 12.18.130.140:80 maxconn 2000 weight 1  check inter 1s rise 2 fall 2

3、重启haproxy
# systemctl start haproxy

四、客户端访问 地址

12.18.130.137  

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

邢函数

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值