Docker Registry 2 frontend with HAProxy and SSL

All our services run on Docker and are load balanced using HAProxy. One of those services is Docker Registry 2.

If you have the same case, the configuration for proxy/LB Docker Registry 2 using HAproxy via SSL is not that sreightforward.
So here is a working and ready configuration for that:

frontend registry  
        # we need to bind both to http and https
        # because registry communication will fail
        bind FrontendIP:80
        bind FrontendIP:443 ssl crt /etc/ssl/registry.pem
        option forwardfor
        http-request set-header X-Forwarded-Proto https if { ssl_fc }
        redirect scheme https if !{ ssl_fc }
        acl host_registry hdr(host) -i yourRegistry.domain.com
        use_backend registry-cluster if host_registry

backend registry-cluster  
    redirect scheme https if !{ ssl_fc }
    balance roundrobin
    server node1 registryNode1IP:5000 check
    server node2 registryNode2IP:5000 check
hire us

Let’s talk about Mobile Apps

We’d love to design, develop and release them for you.

Highest DevOps Standards

Our team wield the right skills to make things work.

Angular magic in the making

Most flexible development technology for stunnig results.

Web Apps cooked the right way

The ultimate combination of code, design and user experience.

Django REST Framework

TEONITE develops, supports and donates open source projects.