经过大量的谷歌搜索,我终于让我的haproxy ssl工作了。但是现在我遇到了问题,因为没有安装root和中间证书所以我的ssl没有绿色条。
我的haproxy配置
global
maxconn 4096
nbproc 1
#debug
daemon
log 127.0.0.1 local0
defaults
mode http
option httplog
log global
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend unsecured
bind 192.168.0.1:80
timeout client 86400000
reqadd X-Forwarded-Proto:\ http
default_backend www_backend
frontend secured
mode http
bind 192.168.0.1:443 ssl crt /etc/haproxy/cert.pem
reqadd X-Forwarded-Proto:\ https
default_backend www_backend
backend www_backend
mode http
balance roundrobin
#cookie SERVERID insert indirect nocache
#option forwardfor
server server1 192.168.0.2:80 weight 1 maxconn 1024 check
server server2 192.168.0.2:80 weight 1 maxconn 1024 check
192.168.0.1是我的负载均衡器ip。 /etc/haproxy/cert.pem包含私钥和域证书,例如。 www.domain.com
有another question with ssl configuration,其中包括bundle.crt。当我联系我的ssl支持时,他们告诉我需要安装root和中间证书。
从Comodo Documentation开始,创建捆绑包很简单,就像合并他们的crt一样。
但是当我尝试将我的haproxy配置重新配置为
时bind 192.168.0.1:443 ssl crt /etc/haproxy/cert.pem ca-file /path/to/bundle.crt
我得到错误,我无法在bind上使用该配置参数。
p.s im使用1.5 dev12版本。使用最新的dev17版本,我甚至在启动haproxy as on this post
时遇到了问题
答案 0 :(得分:38)
看起来你需要像这样重新编译:
make clean
make \
TARGET="linux26" \
USE_STATIC_PCRE=1 \
USE_OPENSSL=1
make install PREFIX="/opt/haproxy"
之后,bind
应该识别您的crt选项。
就我而言,我用过:
bind 0.0.0.0:443 ssl crt /envs/production/ssl/haproxy.pem
我将所有ssl文件连接到订单证书链中的1个大文件私钥中。 e.g:
-----BEGIN MY CERTIFICATE-----
-----END MY CERTIFICATE-----
-----BEGIN INTERMEDIATE CERTIFICATE-----
-----END INTERMEDIATE CERTIFICATE-----
-----BEGIN INTERMEDIATE CERTIFICATE-----
-----END INTERMEDIATE CERTIFICATE-----
-----BEGIN ROOT CERTIFICATE-----
-----END ROOT CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY-----
-----END RSA PRIVATE KEY-----
重新启动,并使用openssl s_client -connect 127.0.0.1:443 -servername www.transloadit.com |head
进行测试。
它应该返回正确的证书信息。
编辑:我刚刚通过HackerNews发现了这个教程:https://serversforhackers.com/c/using-ssl-certificates-with-haproxy。认为随着它更详细地添加将是有用的。
答案 1 :(得分:0)
抱歉,我不确定哪个版本的haproxy是可用的USE_OPENSSL选项...我在代码库中找不到该选项是V 1.4.24
Valid USE_* options are the following. Most of them are automatically set by
# the TARGET, others have to be explictly specified :
# USE_CTTPROXY : enable CTTPROXY on Linux (needs kernel patch).
# USE_DLMALLOC : enable use of dlmalloc (see DLMALLOC_SRC) patch).
# USE_EPOLL : enable epoll() on Linux 2.6. Automatic. patch).
# USE_GETSOCKNAME : enable getsockname() on Linux 2.2. Automatic. patch).
# USE_KQUEUE : enable kqueue() on BSD. Automatic. patch).
# USE_MY_EPOLL : redefine epoll_* syscalls. Automatic. patch).
# USE_NETFILTER : enable netfilter on Linux. Automatic.patch).
# USE_PCRE : enable use of libpcre for regex. Recommended.patch).
# USE_POLL : enable poll(). Automatic.patch).
# USE_REGPARM : enable regparm optimization. Recommended on x86.patch).
# USE_SEPOLL : enable speculative epoll(). Automatic.patch).
# USE_STATIC_PCRE : enable static libpcre. Recommended.patch).
# USE_TPROXY : enable transparent proxy. Automatic. patch).
# USE_LINUX_TPROXY : enable full transparent proxy. Automatic. patch).
# USE_LINUX_SPLICE : enable kernel 2.6 splicing. Automatic. patch).
# USE_LIBCRYPT : enable crypted passwords using -lcrypt patch).
# USE_CRYPT_H : set it if your system requires including crypt.h