码迷,mamicode.com
首页 > 其他好文 > 详细

Haproxy支持SSL配置

时间:2017-03-31 22:21:23      阅读:1583      评论:0      收藏:0      [点我收藏+]

标签:haproxy ssl https

    Haproxy 版本需要在1.5以上才支持SSL

    haproxy 代理 ssl 有两种方式

        1、haproxy 本身提供ssl 证书,后面的web 服务器走正常的http ,这种方式需要重新编译haproxy

        2、haproxy 本身只提供代理,后面的web服务器https,这种方式不需要重新编译

    方式一:

    重新编译安装

make TARGET=linux3100 USE_OPENSSL=1 ADDLIB=-lz clean all
make install
[root@localhost haproxy]# ldd haproxy  | grep ssl
        libssl.so.10 => /lib64/libssl.so.10 (0x00007f5ab8264000)

    修改haproxy.cfg配置文件

global 
tune.ssl.default-dh-param 2048         //修改默认使用2048bit加密,不设置会有警告
 
frontend http-in
bind *:443 ssl crt /root/server.pem      //配置ssl支持,这里pem文件是证书和私钥合并而成的, cat servername.crt servername.key |tee servername.pem
reqadd X-Forwarded-Proto:\ https      //http和https并存
redirect scheme https if !{ ssl_fc }      //http跳转https

    方式二:

需要后置服务器本身支持https,那么只要进行如下配置:
frontend https
    bind *:443
    mode tcp
    default_backend weblogic
 
backend weblogic
    mode tcp
    balance source
server s1 10.20.2.233:443
注意,这种模式下mode 必须是tcp 模式


Haproxy支持SSL配置

标签:haproxy ssl https

原文地址:http://11538244.blog.51cto.com/11528244/1912152

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!