TLS Termination

We collect log files on one site and then send them over the internet via TCP + TLS to our servers in the cloud. The log files need to be sent evenly between the two servers, so we have put HAProxy infront of them.

Currently the only config I have added to get the connection from the local server to the servers in the cloud via HAPRoxy is:

listen graylog 
    bind *:20000
    mode tcp
    option tcplog
    balance roundrobin
    server graylog1 check
    server graylog2 check

I believe I need to terminate TLS at the HAProxy server, how would I go about doing this?



I’ve still got nowhere, can anyone help?

What do you need to encrypt: client to haproxy, haproxy to backend servers, or both? Do you have a certificate ready to be installed on haproxy?

So the logs come to HAproxy encrypted, we want to decrypt them at that point and send them in plaintext from the backend. I am about to set up a certificate for it now.

Ok, the add ssl crt /path/to/certificate to the bind line.

You can find a more complete and secure example here:

I have added that option and it doesn’t seem to have worked.

frontend gl-frontend
    mode tcp
    default_backend gl-cluster
    bind *:20000 ssl crt /etc/certs/ha-selfsigned.pem

backend gl-cluster
        mode tcp
        balance roundrobin
        server GL1
        server GL2

Doesn’t work how? Can you elaborate a little bit?

Okay so the ssl termination is now working, but it only sends to one host. The connection is never broken.


We send the data on from the proxy to two nodes and we are only seeing one connection being made to one node and the connection is never broken and therefore data is never send to the other node.

So the connection when sending the logs from one site to another is just one long TCP connection that sends all the logs. Obviously haproxy is set up to balance the TCP connections and when there’s only one, it will just go to one node. Is there anyway to resolve this?

To load-balance you need multiple sessions. If there is only one session, only one server will see the load.

This is especially true in TCP mode, as haproxy does not understand and interact at application layer, but on layer 4 (TCP) only.