2013-02-24 317 views
15

經過大量的谷歌搜索,我終於使我的haproxy ssl工作。但現在我得到了問題,因爲根和中間證書沒有安裝,所以我的ssl沒有綠色條。Haproxy 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支持時,他們告訴我我需要安裝根證書和中級證書。

Comodo Documentation,創建捆綁包很簡單,因爲合併他們的crt,我做了。

但是當我試圖重新配置我的HAProxy的配置爲

,我不能使用的配置參數上綁定
bind 192.168.0.1:443 ssl crt /etc/haproxy/cert.pem ca-file /path/to/bundle.crt 

即時得到錯誤。

p.s im使用1.5 dev12版本。隨着最新版本dev17我有問題,甚至開始HAProxy的as on this post

enter image description here

+0

你應該[關閉的SSLv3(HTTP:/ /blog.haproxy.com/2014/10/15/haproxy-and-sslv3-poodle-vulnerability/)with bind 192.168.0.1:443 ssl crt /etc/haproxy/cert.pem ca-file/path/to/bundle.crt no-sslv3' – 2016-12-15 11:57:28

回答

35

它看起來你需要重新編譯,像這樣:

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個大文件,私鑰。例如: -

-----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。認爲添加更多細節會很有用。

+0

虐待嘗試,但你可以告訴我我的證書訂單,https://support.comodo.com/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=1209 – 2013-03-06 18:09:08

+2

已更新答案,以顯示確切的順序證書。 – kvz 2013-03-21 15:52:59

+0

沒有必要發送根證書,因爲客戶端在其信任存儲中擁有該證書,否則它將不被信任。 – 2016-07-26 21:54:38

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 
+1

嘗試1.5+版本不是1.4+。但是1。5仍然是「開發」版本,但它在我的生產中正常工作 – 2013-10-27 17:26:55

+0

截至2014年6月19日,HAProxy 1.5 stable已發佈 – kvz 2014-07-15 09:49:18