title: Creating a Private Docker Registry with Authentication
body: <p>So I am trying to run my own docker registry with authentication so I can access it externally. To do this I am using the docker registry image from the docker hub like so:</p>
  
  <pre><code>docker run -p 5000:5000 -d -v /opt/registry:/tmp/registry registry:0.8.1
  </code></pre>
  
  <p>I am then using HAProxy to link this to the URL <code>reg.mydomain.com</code> and add the authentication:</p>
  
  <pre><code>userlist auth_list
      group registry users root
      user root password [password]
  
  backend docker-registry
      mode http
      server localhost:5000_localhost localhost:5000 cookie localhost:5000_localhost
  
  frontend web
      mode http
      bind *:80
      bind *:443 ssl crt /path/to/ssl.pem
      acl domain hdr(host) -i reg.mydomain.com
      acl auth_docker_registry http_auth_group(auth_list) registry
      acl registry_ping url_sub _ping
      http-request auth realm Registry if !auth_docker_registry domain !registry_ping
      use_backend docker-registry if domain
  </code></pre>
  
  <p>Once that was running I logged in using this command: </p>
  
  <pre><code>root@mydomain:~# docker login https://reg.mydomain.com
  Username: root
  Password:
  Email:
  Login Succeeded
  </code></pre>
  
  <p>The problem is, when I run a command to either push or pull the the registry I get these errors:</p>
  
  <pre><code>root@mydomain:~# docker pull reg.mydomain.com/project1
  The push refers to a repository [reg.mydomain.com/project1] (len: 1)
  Sending image list
  Pushing repository reg.mydomain.com/project1 (1 tags)
  511136ea3c5a: Pushing
  2014/11/24 20:40:33 HTTP code 401, Docker will not send auth headers over HTTP.
  
  root@mydomain:~# docker pull reg.mydomain.com/project1
  Pulling repository reg.mydomain.com/project1
  2014/11/24 20:40:38 Could not reach any registry endpoint
  </code></pre>
  
  <p>My guess at what the problem was is that the HTTPS connection is terminated at HAProxy and the rest of the connection (between HAProxy and Docker Registry container) is HTTP but the authentication header is still present resulting in the error on pushing. To test this I add <code>reqidel ^Authorization</code> to backend section of the HAProxy configuration to no avail. </p>
  
  <p>It is also worth noting I can navigate <code>https://reg.mydomain.com</code> and sub directories such as <code>/v1/_ping</code> in a web browser and it all works as expected (I have to log in, etc.). Also, at the time of writing, I am using docker registry version <code>0.8.1</code> rather than <code>0.9</code> as the <code>0.9</code> image doesn't start.</p>
  
  <p>If there is any additional information required, please let me know.</p>
  
  <p>Thanks, JamesStewy</p>