Enable SSL in Haproxy Docker Container

I have a haproxy container running on port 80. This container is started with command

This haproxy used following configuration file /home/ubuntu/haproxy/haproxy.cfg

To make this haproxy work with SSL, first create a ssl.pem file with your SSL certificate contents in following order

copy and paste all those certs into ssl.pem file inside /home/ubuntu/haproxy/ssl.pem

Now modify your /home/ubuntu/haproxy/haproxy.cfg file as follows

Now we need to stop current docker container as it only allow port 80 to be shared.

Lets create a new haproxy container with port 443 forwaded.

See Haproxy

Haproxy Site With SSL

To handle SSL/HTTPS traffic on haproxy, use following config in your /etc/haproxy/haproxy.cfg file.


SSL certificate of your domain in PEM format. This is done by using combining your SSL cert, private key and ca bundle.

If you have more sites with SSL, you can specify SSl certs like


This is IP of your back end server.

Restart Haproxy with