docker-registry icon indicating copy to clipboard operation
docker-registry copied to clipboard

Basic Auth with Nginx Requires user/pass to be part of login command

Open behemphi opened this issue 12 years ago • 6 comments

  • Set up a private registry at this URL: https://docker-repo.stackengine.com
  • Test connection via browser (https://docker-repo.stackengine.com:8080), authenticate and get response: "docker-registry server (dev) (v0.8.1)"
  • Test version endpoint via browser (https://docker-repo.stackengine.com:8080/v1/_ping), get response: true
  • Attempt docker login https://docker-registry.stackengine.com:8080 but get error message
Username: fooserName
Password: xkcdcom936
Email: [email protected]
2014/11/09 16:20:19 Error response from daemon: Invalid registry endpoint https://docker-repo.stackengine.com:8080/v1/: Get https://docker-repo.stackengine.com:8080/v1/_ping: x509: certificate signed by unknown authority. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry docker-repo.stackengine.com:8080` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/docker-repo.stackengine.com:8080/ca.crt
  • Note in the nginx error log:
2014/11/10 03:38:51 [error] 12836#0: *85 no user/password was provided for basic authentication, client: 66.249.65.64, server: docker-repo.stackengine.com, request: "GET / HTTP/1.1", host: "docker-repo.stackengine.com:8080"
  • Attempt docker login https://foosername:[email protected]:8080
  • Type in same auth details as on the command line
  • Get success
  • NOTE: At this point I can push and pull from the repo locally and remotely.
Account created. Please see the documentation of the registry  https://foosername:[email protected]:8080/v1/ for instructions how to activate it.

_Extra Credit_ 

* Attempt to go to recommended URL (https://foosername:[email protected]:8080/v1/) in browser and get a 404 with nginx saying no user/pass provided again in the error log.
* Attempt to go to (https://docker-repo.stackengine.com:8080/v1/), do _not_ get challenged by basic auth, however still get 404.  

behemphi avatar Nov 10 '14 15:11 behemphi

@bacongobbler @wking you are the experts for these :-)

dmp42 avatar Nov 10 '14 17:11 dmp42

On Mon, Nov 10, 2014 at 07:23:48AM -0800, Boyd Hemphill wrote:

2014/11/09 16:20:19 Error response from daemon: … x509: certificate signed by unknown authority…

You need the CA signing your registry's cert in your local list of root certificates. See 1.

wking avatar Nov 10 '14 17:11 wking

We can probably use some words in the FAQ or ADVANCED doc.

dmp42 avatar Nov 10 '14 17:11 dmp42

On Mon, Nov 10, 2014 at 09:42:41AM -0800, Olivier Gambier wrote:

We can probably use some words in the FAQ or ADVANCED doc.

This is a client issue (in this case, the Docker engine/daemon), but you're most likely to hit it if you're running your own registry, so sure. I don't know if we have a particularly good place to put it though. Something like:

“If you're using an uncommon root CA (e.g. for a self-signed cert), make sure your users install that CA in their client's list of root CAs. For folks using the Docker engine as a registry client, that's their OpenSSL implementation's default path (I think ;). For folks who are managing their OpenSSL root certs with ca-certificates, you can do that by dropping your CA cert under /usr/local/share/ca-certificates and running update-ca-certificates. You'll need to restart your OpenSSL-using client so it notices the new CA certs.”

That's a lot of ifs for this particular issue, but the real solution to this would be giving folks a better understanding of their OpenSSL config, and there's no good place in the Docker docs to do that ;).

wking avatar Nov 10 '14 18:11 wking

Let's try to add some basic stuff in there: https://github.com/docker/docker-registry/blob/master/FAQ.md

dmp42 avatar Nov 10 '14 18:11 dmp42

I realize that I was not clear when I say that this is not a self signed certificate. It is from a recognized authority.

It could be I don't understand my ssl config as stated, however I don't see the connection here.

If I sign in by providing my username and password in the URI, the private registry works as expected. I can push, pull and so on.

If, however I sign in using the prompts, I get an error.

This dichotomy seems to indicate that SSL is properly configured and that the client is doing something unusual when passing the prompt information to the registry.

Thanks for taking the time on this!

behemphi avatar Nov 13 '14 21:11 behemphi