一、实验环境

一、准备后端服务器

# yum -y install nginx
# echo "10.0.0.7" > /usr/share/nginx/html/index.html #web1
# echo "10.0.0.17" > /usr/share/nginx/html/index.html #web2
# systemctl restart nginx

二、准备CA证书

实现自签名CA证书,请参考章节:实现https

合并证书文件

cat demo.key demo.crt > demo.pem
mv demo.pem /etc/haproxy/certs/haproxy.pem

三、配置haproxy

# yum -y install haproxy
# cat /etc/haproxy/haproxy.cfg |grep -v "^#" global
# to have these messages end up in /var/log/haproxy.log you will
# need to:
#
# 1) configure syslog to accept network log events. This is done
# by adding the '-r' option to the SYSLOGD_OPTIONS in
# /etc/sysconfig/syslog
#
# 2) configure local2 events to go to the /var/log/haproxy.log
# file. A line like the following can be added to
# /etc/sysconfig/syslog
#
# local2.* /var/log/haproxy.log
#
log 127.0.0.1 local2 chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon # turn on stats unix socket
stats socket /var/lib/haproxy/stats # utilize system-wide crypto-policies
ssl-default-bind-ciphers PROFILE=SYSTEM
ssl-default-server-ciphers PROFILE=SYSTEM 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
maxconn 3000 frontend http_port
bind 10.0.0.8:80
bind 10.0.0.8:443 ssl crt /etc/haproxy/certs/haproxy.pem #实现CA
redirect scheme https if !{ ssl_fc } #实现https跳转
balance roundrobin
default_backend web_hosts
backend web_hosts
balance roundrobin
server web1 10.0.0.7:80 check inter 2000 fall 3 rise 5
server web2 10.0.0.17:80 check inter 2000 fall 3 rise 5 #重启haproxy服务
# systemctl restart haproxy

四、访问测试

[root@7-2 ~]#while :;do curl https://10.0.0.8 -k;sleep 0.5;done
10.0.0.17
10.0.0.7
10.0.0.17
10.0.0.7
10.0.0.17
10.0.0.7
....

在Windows客户端访问10.0.0.8,实现了自动跳转https

haproxy https实现的更多相关文章

  1. ca 自签名证书 并实现HAProxy https功能

    mkdir /etc/ssl/xip.io [root@ha02 haproxy-]# openssl genrsa - Generating RSA bit long modulus ....... ...

  2. 负载均衡服务之HAProxy https配置、四层负载均衡以及访问控制

    前文我们聊了下haproxy的访问控制ACL的配置,回顾请参考https://www.cnblogs.com/qiuhom-1874/p/12817773.html:今天我们来聊一聊haproxy的h ...

  3. laravel + haproxy + https 后生成分页 url 非 https 解决办法

    更合适的解决办法:在 AppServiceProvider boot 方法中使用 \URL::forceScheme('https'); 即可. 背景 近日对所有的客户都上线了 https ,本来在 ...

  4. 用HAProxy和KeepAlived构建高可用的反向代理

      用HAProxy和KeepAlived构建高可用的反向代理 用HAProxy和KeepAlived构建高可用的反向代理 前言对于访问量较大的网站来说,随着流量的增加单台服务器已经无法处理所有的请求 ...

  5. 关于haproxy

    高性能负载均衡软件 haproxy 一.四层和七层负载均衡的区别: 所谓的四层就是OSI参考模型中的第四层,四层负载均衡也称为四层交换机,他主要是通过分析IP层及TCP/UDP层的流量实现的基于IP加 ...

  6. 用HAProxy和KeepAlived构建高可用的反向代理系统

    对于访问量较大的网站来说,随着流量的增加单台服务器已经无法处理所有的请求,这时候需要多台服务器对大量的请求进行分流处理,即负载均衡.而如果实现负载均衡,必须在网站的入口部署服务器(不只是一台)对这些请 ...

  7. Haproxy与OpenStack-API安全

    转 http://wsfdl.com/devops/2014/12/24/Haproxy%E4%B8%8EOpenStack-API%E5%AE%89%E5%85%A8.html Haproxy 作为 ...

  8. haproxy mycat mysql 读写分离MHA高可用

    主机IP信息 hostname IP 172.16.3.140 haproxy01 172.16.3.141 haproxy02 172.16.3.142 mycat01 172.16.3.143 m ...

  9. 在Windows进下build 高可用负载均衡与反向代理神器:HAProxy

    前言 HAProxy是一个款基于Linux的开源高可用的负载均衡与反向代理工具,与Nginx大同小异. 搜遍了全网,几乎都是基于Linux平台.Windows平台的要么就是多年前的旧版本,要么就是不兼 ...

随机推荐

  1. Sentry 企业级数据安全解决方案 - Relay 项目配置

    内容整理自官方文档 系列 Sentry 企业级数据安全解决方案 - Relay 入门 Sentry 企业级数据安全解决方案 - Relay 运行模式 Sentry 企业级数据安全解决方案 - Rela ...

  2. Android官方文档翻译 二 1.Building Your First App

    Building Your First App 创建你的第一个App项目 Dependencies and prerequisites 依赖关系和先决条件 * Android SDK * ADT Pl ...

  3. 【刷题-LeetCode】164 Maximum Gap

    Maximum Gap Given an unsorted array, find the maximum difference between the successive elements in ...

  4. android+opencv+opencl: cv::dft()的opencl版本的性能分析

    在小米mix 2s + 高通骁龙 845 + Adreno 630 上测试了opencl版本的cv::dft(). 测试数据 先看表格里面的描述: 名称 函数名 最大时间(ms) 平均时间(ms) 说 ...

  5. eclipse不能创建web项目,如何设置(亲测可用)

    具体描述:就是在项目右键或者file-->new的时候没有dynamic web project选项)(我这里已经解决.所以看得到) 根本原因:就是有没有web的开发插件 两种办法 1.下载使用 ...

  6. C++Template(类模板二)

    namespace _myspace{ template<typename T, typename U> class TC { public: TC() { cout << & ...

  7. Tomcat-IDEA整合Tomcat服务器

    Tomcat(IDEA整合Tomcat服务器) 可以加多个版本tomcat

  8. python语法缩进

    1.python会根据缩进来判断代码行和前一句代码行之间的关系 2.for循环后一定要缩进,for循环后面的冒号代表告诉python,下面是代码行缩进的第一行

  9. expect.sh

    #!/usr/bin/expect spawn /usr/bin/ssh root@192.168.43.43 -p 22 expect "password:" send &quo ...

  10. 如何快速写出高质量的 Go 代码?

    前言 团队协作开发中,必然存在着不同的代码风格,并且诸如 http body close,unhandled error 等低级错误不能完全避免.通过使用 ci lint 能够及早的发现并修复问题,提 ...