haproxy ssl测试

haproxy终于还是打算直接支持ssl了,目前是放出了一个http://haproxy.1wt.eu/download/1.5/src/snapshot/haproxy-ss-20120904.tar.gz的。简单的测试了一下,现在是可以跑起来的。



global  
log 127.0.0.1 local1 notice  
maxconn 40960  
uid 99  
gid 99  
nbproc 4  
daemon  
stats socket /opt/haproxyssl/haproxy.stats level admin

defaults  
log global  
mode http  
option dontlognull  
retries 3  
option redispatch  
maxconn 2000  
contimeout 5000  
clitimeout 50000  
srvtimeout 50000  
frontend https  
bind-process 1,2  
bind :443 ssl /opt/haproxyssl/cert2/mulapp.crt  
default_backend http  
backend http  
bind-process 3  
mode http  
server pp1 127.0.0.1:80 weight 10 check inter 2000 rise 2 fall 4  
listen stats 0.0.0.0:8000  
maxconn 10  
bind-process 4  
mode http  
stats refresh 30s  
stats uri /stats  
stats realm haproxy  
stats auth admin:admin

目前还没有证书的文档说明具体怎么用,只是邮件列表有提到,就照着配置了一下。可以使用bind-process把负责接收请求和ssl加解密的单独绑定到特定的进程。bind后面的ssl指令是指定ssl证书的,需要注意的是证书的格式是和stunnel用的类似的。对于证书链的配置是把依次把服务器证书,…,根证书追加到文件,然后再 把key追加到最后,我也试过直接把key放最前面也是可以的,看来是可以自动识别出来的。