2013-08-29 45 views
2

我試圖通過https連接到2個後端服務器使用端口443,並且我想找到一種方法將密鑰&證書文件發送到後端的服務器。我的haproxy.cfg是:Haproxy 1.4連接到https後端服務器

global 
    log 127.0.0.1 local0 
    log 127.0.0.1 local1 notice 
    #log loghost local0 info 
    maxconn 4096 
    #chroot /usr/share/haproxy 
    user haproxy 
    group haproxy 
    daemon 
    #debug 
    #quiet 

defaults 
    log  global 
    mode http 
    option httplog 
    option dontlognull 
    retries 3 
    option redispatch 
    maxconn 2000 
    contimeout 5000 
    clitimeout 50000 
    srvtimeout 50000 

listen stats :8000 
    #mode http 
    stats enable 
    stats realm Haproxy\ Statistics 
    stats uri/
    stats auth admin:password 


listen ssl-relay :80 
    mode tcp 
    balance roundrobin 
    stick-table type ip size 200m expire 30m 
    stick on src 
    server server01 www.example.com:443 check inter 2000 fall 3 
    server server02 www.example.com:443 check inter 2000 fall 3 

如何才能使haproxy服務器和後端服務器之間的通信安全?

回答

1

haproxy 1.4不支持SSL。要麼更新到1.5,要麼使用類似stunnel的東西。

我已經在一個非常大的企業實施中使用了這兩種產品,並且效果很好。如果你想堅持使用haproxy 1.4,那麼stunnel路線非常簡單。只需在haproxy服務器上安裝stunnel,在本地端口上偵聽,讓haproxy連接到本地端口,然後配置stunnel以指向遠程https端點。除了在安全通道的全局設置,實際的配置是3線

  1. 監聽本地主機
  2. 目標端口的主機和端口
2

將你的客戶使用https://myfakepage.com:80的網址是什麼?如果沒有,那麼你在做什麼是毫無意義的。您正在處理與前端的未加密連接,然後與後端進行加密連接。問題是,當連接返回到客戶端時,它將不加密,所以你不會購買任何東西。如果您的客戶將使用https://pmyfakepage.com:80,那麼無需執行任何操作,因爲haproxy已經充當https流量的傳遞。

你試圖做的負載平衡器SSL終止,如果是的話你倒着做

你綁定secion會看起來像

frontend ssl-site 
bind *:443 ssl crt /path/to/bundle.pem #you need to make sure the whole cert path is in one pem file 
reqadd X-Forwarded-Proto:\ https 
default_backend myServers 

backend myServers 
balance roundrobin 
server server1 www.example.com:80 
server server2 www2.example.com:80 

但dtorgo指出,SSL終止在這種方式只適用於1.5以上。如果您發現通道太慢,另一種選擇是螺柱。

希望這可以解決你的問題。