配置HAProxy支持https协议
author:JevonWei
版权声明:原创作品
实现http重定向到https
HAProxy
创建CA证书
[root@HAProxy ~]# cd /etc/haproxy/
[root@HAProxy haproxy]# mkdir certs
[root@HAProxy haproxy]# cd /etc/pki/CA
[root@HAProxy CA]# (umask 077;openssl genrsa -out private/cakey.pem 4096)
[root@HAProxy CA]# openssl req -new -x509 -key private/cakey.pem -out cacert.pem -days 365 \\自签名证书
[root@HAProxy CA]# touch index.txt
[root@HAProxy CA]# echo 01 > serial
[root@HAProxy CA]# cd /etc/haproxy/certs/
[root@HAProxy certs]# openssl genrsa -out haproxy.key 2048
[root@HAProxy certs]# openssl req -new -key haproxy.key -out haproxy.csr
[root@HAProxy certs]# [root@HAProxy certs]# openssl ca -in haproxy.csr -out haproxy.crt
[root@HAProxy certs]# ls
haproxy.crt haproxy.csr haproxy.key
[root@HAProxy certs]# cat haproxy.crt haproxy.key > haproxy.pem
[root@HAProxy certs]# ll
total 12
-rw-r--r--. 1 root root 0 Aug 29 19:36 haproxy.crt
-rw-r--r--. 1 root root 1009 Aug 29 19:35 haproxy.csr
-rw-r--r--. 1 root root 1675 Aug 29 19:34 haproxy.key
-rw-r--r--. 1 root root 1675 Aug 29 19:37 haproxy.pem
[root@HAProxy certs]# chmod 600 haproxy.pem
配置haproxy网页跳转
[root@HAProxy ~]# vim /etc/haproxy/haproxy.cfg
frontend https *:443
bind *:443 ssl crt /etc/haproxy/certs/haproxy.pem
acl static path_end .jpg .jpeg .png .gif .txt .html
acl static path_beg /imgs /images /css
use_backend staticsrvs if static
default_backend dynsrvs
frontend http
bind *:8080
redirect scheme https if !{ ssl_fc }
backend dynsrvs
balance roundrobin
server dynsrv1 172.16.253.105:80 check
server dynsrv2 172.16.253.105:8080 check
backend staticsrvs
balance roundrobin
server staticsrv1 172.16.253.191:80 check
server staticsrv2 172.16.253.191:8080 check
[root@HAProxy ~]# systemctl restart haproxy
配置haproxy主页跳转,即访问的http的所有内容都跳转到https的默认主页上
[root@HAProxy ~]# vim /etc/haproxy/haproxy.cfg
frontend https *:443
bind *:443 ssl crt /etc/haproxy/certs/haproxy.pem
acl static path_end .jpg .jpeg .png .gif .txt .html
acl static path_beg /imgs /images /css
use_backend staticsrvs if static
default_backend dynsrvs
frontend http
bind *:8080
redirect location https://172.16.253.108/ if !{ ssl_fc }
backend dynsrvs
balance roundrobin
server dynsrv1 172.16.253.105:80 check
server dynsrv2 172.16.253.105:8080 check
backend staticsrvs
balance roundrobin
server staticsrv1 172.16.253.191:80 check
server staticsrv2 172.16.253.191:8080 check
[root@HAProxy ~]# systemctl restart haproxy
client访问测试
配置HAProxy支持https协议的更多相关文章
- Nginx配置支持https协议-应用实践
Nginx配置支持https协议-应用实践 https简介 HTTPS 是运行在 TLS/SSL 之上的 HTTP,与普通的 HTTP 相比,在数据传输的安全性上有很大的提升. TLS是传输层安全协议 ...
- loadrunner支持https协议的操作方法-经验总结
问题:用户portal支持https协议,用loadrunner录制登陆脚本时发现未录制到用户名和密码 录制到的脚本如下: login() { lr_think_time(10); web_url(& ...
- 1、大部分社交平台接口不支持https协议。
参考文献来自:http://wiki.mob.com/ios9-%E5%AF%B9sharesdk%E7%9A%84%E5%BD%B1%E5%93%8D%EF%BC%88%E9%80%82%E9%85 ...
- CentOS6.5 下在Nginx中添加SSL证书以支持HTTPS协议访问
参考文献: 1. NginxV1.8.0安装与配置 2. CentOS下在Nginx中添加SSL证书以支持HTTPS协议访问 3. nginx配置ssl证书的方法 4.nginx强制使用https访问 ...
- 配置Tomcat使用https协议(配置SSL协议)
配置Tomcat使用https协议(配置SSL协议) 2014-01-20 16:38 58915人阅读 评论(3) 收藏 举报 转载地址:http://ln-ydc.iteye.com/blog/1 ...
- Python内置的urllib模块不支持https协议的解决办法
Django站点使用django_cas接入SSO(单点登录系统),配置完成后登录,抛出“urlopen error unknown url type: https”异常.寻根朔源发现是python内 ...
- curl提示不支持https协议解决方法
根据网上的资料,这个问题的原因是因为在安装curl时使用默认安装,但是默认安装并不支持https协议 简单粗暴的办法就是,卸载重新安装curl(有一种方法是重新编译就可以了,然后使用编译后的可执行文件 ...
- centos7.3下curl支持https协议
1 由于自己的curl是默认安装的,查看了下 不支持https协议 [root@izwz90bp6do7s3cr45cw6az ~]# curl --version curl (x86_64-redh ...
- 配置nginx支持Https
配置nginx支持Https一定要先使用stop停止nginx然后重新代开不能使用reload 一:安装letsencrypt 1.从git上克隆下来git clone https://github. ...
随机推荐
- 构建 MariaDB Galera Cluster 分布式数据库集群(二)
MariaDB的安装 构建 MariaDB Galera Cluster之前,首先安装MariaDB,本文使用的版本是10.1 1.环境准备 主机: MariaDB01(192.168.56.102) ...
- OPNET中FIN,FOUT以及FRET的作用 分类: opnet 2014-05-12 16:07 144人阅读 评论(0) 收藏
为了使一个用户定义的函数被执行,该函数必须与一个特殊的堆栈跟踪代码相连.堆栈跟踪技术靠在函数的入口点和出口点插入预处理器宏指令完成(一个函数只有一个入口点,但可以有多个出口点(由C语言的return声 ...
- Hello ReactJS
前言 React学习前先搭好环境,官网的例子看着比较分散.结合webpack就可以体验完整的es6开发流程了. 源码:https://github.com/Ryan-Miao/hello-react- ...
- bzoj3728: PA2014Final Zarowki
Description 有n个房间和n盏灯,你需要在每个房间里放入一盏灯.每盏灯都有一定功率,每间房间都需要不少于一定功率的灯泡才可以完全照亮. 你可以去附近的商店换新灯泡,商店里所有正整数功率的 ...
- Javascript跨域后台设置拦截
子域名之间互相访问需要跨域 结论放在开头: 服务端必须设置允许跨域 客户端带cookie需要设置withCredentials 无论服务端是否允许跨域,该request都会完整执行 options预请 ...
- 43. leetcode 459. Repeated Substring Pattern
459. Repeated Substring Pattern Given a non-empty string check if it can be constructed by taking a ...
- Python Socket 简单聊天室2
上篇文章写了一个简单的单线程的一问一答的简单聊天室.这次我们使用SocketServer模块搭建一个多线程异步的聊天室. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ...
- NYOJ--46--最少乘法次数
最少乘法次数 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 给你一个非零整数,让你求这个数的n次方,每次相乘的结果可以在后面使用,求至少需要多少次乘.如24:2*2 ...
- UIButton防止被重复点击
一.避免屏幕内多个 UIButton 被重复点击 1.在 AppDelegate 中添加[[UIButton appearance] setExclusiveTouch:YES]; 2.button. ...
- 怎样做才是最优雅方式切换 web 项目数据源 ?
随着业务变迁/需求变更,JavaEE 应用中会被迫连接多个数据源进行业务处理. 怎样在不影响原有项目结构的情况下,已最优雅/最简洁的方式动态切换数据源呢? 本文已一次添加数据源后动态切换实践为例,描述 ...