{"action":"created","issue":{"url":"https://api.github.com/repos/docker/distribution/issues/1021","labels_url":"https://api.github.com/repos/docker/distribution/issues/1021/labels{/name}","comments_url":"https://api.github.com/repos/docker/distribution/issues/1021/comments","events_url":"https://api.github.com/repos/docker/distribution/issues/1021/events","html_url":"https://github.com/docker/distribution/issues/1021","id":108075455,"number":1021,"title":"err=no successful auth challenge for http://localhost/v2/ - errors: [] statusCode=500","user":{"login":"wemeya","id":12540577,"avatar_url":"https://avatars.githubusercontent.com/u/12540577?v=3","gravatar_id":"","url":"https://api.github.com/users/wemeya","html_url":"https://github.com/wemeya","followers_url":"https://api.github.com/users/wemeya/followers","following_url":"https://api.github.com/users/wemeya/following{/other_user}","gists_url":"https://api.github.com/users/wemeya/gists{/gist_id}","starred_url":"https://api.github.com/users/wemeya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wemeya/subscriptions","organizations_url":"https://api.github.com/users/wemeya/orgs","repos_url":"https://api.github.com/users/wemeya/repos","events_url":"https://api.github.com/users/wemeya/events{/privacy}","received_events_url":"https://api.github.com/users/wemeya/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-09-24T07:38:35Z","updated_at":"2015-09-25T17:43:41Z","closed_at":null,"body":"hello, all.\r\nrecently, I used nginx to authenticate to pull/push images, however, I was confused by the problem as described in the title for several days. I tried several ways but no succeed. any help would be appreciated, thanks. \r\nHere are the details and my relevant confs:\r\ndocker.log:\r\n\r\n```\r\nDEBU[0728] Calling POST /images/create                  \r\nINFO[0728] POST /v1.20/images/create?fromImage=localhost%2Ftest%2Fnginx%3Alatest \r\nDEBU[0728] Trying to pull localhost/test/nginx from https://localhost v2 \r\nDEBU[0728] Error getting v2 registry: Get https://localhost/v2/: dial tcp 127.0.0.1:443: connection refused \r\nDEBU[0728] Trying to pull localhost/test/nginx from https://localhost v1 \r\nDEBU[0728] attempting v2 ping for registry endpoint https://localhost/v2/ \r\nDEBU[0728] attempting v1 ping for registry endpoint https://localhost/v1/ \r\nDEBU[0728] Fallback from error: unable to ping registry endpoint https://localhost/v0/\r\nv2 ping attempt failed with error: Get https://localhost/v2/: dial tcp 127.0.0.1:443: connection refused\r\n v1 ping attempt failed with error: Get https://localhost/v1/_ping: dial tcp 127.0.0.1:443: connection refused \r\nDEBU[0728] Trying to pull localhost/test/nginx from http://localhost v2 \r\nDEBU[0728] Pulling tag from V2 registry: \"latest\"       \r\nDEBU[0728] v2 error: errcode.Error unauthorized: access to the requested resource is not authorized \r\nDEBU[0728] Error trying v2 registry: unauthorized: access to the requested resource is not authorized \r\nDEBU[0728] Trying to pull localhost/test/nginx from http://localhost v1 \r\nDEBU[0728] [registry] Calling GET http://localhost/v1/repositories/test/nginx/images \r\nDEBU[0728] Not continuing with error: Authentication is required. \r\nDEBU[0750] Calling POST /auth                           \r\nINFO[0750] POST /v1.20/auth                             \r\nDEBU[0750] pinging registry endpoint https://localhost/v0/ \r\nDEBU[0750] attempting v2 ping for registry endpoint https://localhost/v2/ \r\nDEBU[0750] attempting v1 ping for registry endpoint https://localhost/v1/ \r\nDEBU[0750] Error from registry \"https://localhost/v0/\" marked as insecure: unable to ping registry endpoint https://localhost/v0/\r\nv2 ping attempt failed with error: Get https://localhost/v2/: dial tcp 127.0.0.1:443: connection refused\r\n v1 ping attempt failed with error: Get https://localhost/v1/_ping: dial tcp 127.0.0.1:443: connection refused. Insecurely falling back to HTTP \r\nDEBU[0750] attempting v2 ping for registry endpoint http://localhost/v2/ \r\nDEBU[0750] attempting v2 login to registry endpoint http://localhost/v2/ \r\nERRO[0750] Handler for POST /auth returned error: no successful auth challenge for http://localhost/v2/ - errors: [] \r\nERRO[0750] HTTP Error                                    err=no successful auth challenge for http://localhost/v2/ - errors: [] statusCode=500\r\n```\r\n\r\nThe directory: \r\n\r\n```\r\nroot@linux-Rev-1-0:/home/linux/registry-compose/nginx# ls\r\ngeo.conf  htpasswd  registry.conf\r\n\r\nregistry.conf:\r\n# Docker registry proxy for api versions 1 and 2\r\n# when pull image, reverse proxy to port:5000, if not find, pass to master \r\nupstream docker-registry{\r\n  server registryv1:5000  weight=2000000000;\r\n  server xx.xx.xx.xx:80  weight=1;\r\n}\r\nupstream docker-registry-v2{\r\n  server registryv2:5000  weight=2000000000;\r\n  server xx.xx.xx.xx:80  weight=1;\r\n}\r\n# No client auth or TLS\r\nserver {\r\n  listen 80;\r\n  server_name  xx.xx.xx.com;\r\n\r\n  # disable any limits to avoid HTTP 413 for large image uploads\r\n  client_max_body_size 0;\r\n  # required to avoid HTTP 411: see Issue #1486 (https://github.com/docker/docker/issues/1486)\r\n  chunked_transfer_encoding on;\r\n  # start with v1, contain 'layer', go to slave to fetch\r\n  location ~ /v1/.*\\/layer$ {\r\n     proxy_next_upstream error timeout invalid_header http_500 http_503 http_504 http_403 http_404 http_502;\r\n     proxy_pass http://docker-registry;\r\n     proxy_set_header  Host              $http_host;   # required for docker client's sake\r\n     proxy_set_header  X-Real-IP         $remote_addr; # pass on real client's IP\r\n     proxy_set_header  X-Forwarded-For   $proxy_add_x_forwarded_for;\r\n     proxy_set_header  X-Forwarded-Proto $scheme;\r\n  }\r\n  # start with v1, not contain 'layer', go to master to fetch\r\n  # The search of regular expressions terminates on the first match\r\n  # so can't change the order of this one with the previous location\r\n  location ~ /v1/.*$ {\r\n     proxy_pass http://xx.xx.xx.xx:80;\r\n  }\r\n  location = /v2/ {\r\n #    auth_basic \"registry.localhost\";\r\n #    auth_basic_user_file /etc/nginx/conf.d/htpasswd;\r\n #    more_set_headers 'Docker-Distribution-Api-Version: registry/2.0';\r\n #    add_header 'Docker-Distribution-Api-Version' 'registry/2.0' always;\r\n     return 200;\r\n  }\r\n  location ~ /v2/.*\\/manifests\\/.*$ {\r\n     proxy_pass http://xx.xx.xx.xx:80;\r\n  }\r\n  location /v2/ {\r\n    # Do not allow connections from docker 1.5 and earlier\r\n    # docker pre-1.6.0 did not properly set the user agent on ping, catch \"Go *\" user agents\r\n       if ($http_user_agent ~ \"^(docker\\/1\\.(3|4|5(?!\\.[0-9]-dev))|Go ).*$\" ) {\r\n         return 404;\r\n       }\r\n\r\n    # To add basic authentication to v2 use auth_basic setting plus add_header\r\n\r\n    # auth_basic \"registry.localhost\";\r\n    # auth_basic_user_file /etc/nginx/conf.d/htpasswd;\r\n    # add_header 'Docker-Distribution-Api-Version' 'registry/2.0' always;\r\n\r\n    #include               docker-registry-v2.conf;\r\n\r\n      if ($request_method = PUT){\r\n        proxy_pass  http://xx.xx.xx.xx:80;\r\n        break;\r\n      }\r\n      #pull images, if exist, pass to port 5000; if not, pass to master server\r\n      proxy_next_upstream error timeout invalid_header http_500 http_503 http_504 http_403 http_404 http_502;\r\n      proxy_pass                          http://docker-registry-v2;\r\n      proxy_set_header  Host              $http_host;   # required for docker client's sake\r\n      proxy_set_header  X-Real-IP         $remote_addr; # pass on real client's IP\r\n      proxy_set_header  X-Forwarded-For   $proxy_add_x_forwarded_for;\r\n  proxy_set_header  X-Forwarded-Proto $scheme;\r\n  }\r\n location / {\r\n\r\n      #when push images--PUT method\r\n      if ($request_method = PUT){\r\n        proxy_pass  http://xx.xx.xx.xx:80;\r\n        break;\r\n      }\r\n      #pull images, if exist, pass to port 5000; if not, pass to master server\r\n      proxy_next_upstream error timeout invalid_header http_500 http_503 http_504 http_403 http_404 http_502;\r\n      proxy_pass                          http://docker-registry;\r\n      proxy_set_header  Host              $http_host;   # required for docker client's sake\r\n      proxy_set_header  X-Real-IP         $remote_addr; # pass on real client's IP\r\n      proxy_set_header  X-Forwarded-For   $proxy_add_x_forwarded_for;\r\n      proxy_set_header  X-Forwarded-Proto $scheme;\r\n      #proxy_set_header  Authorization     \"\"; # For basic auth through nginx in v1 to work, please comment this line\r\n  }\r\n}\r\ngeo.conf:\r\nsatisfy any;\r\nallow 127.0.0.1;\r\n#allow 172.17.42.1;\r\ndeny all;\r\n\r\nauth_basic \"Restrict Access\";\r\nauth_basic_user_file /etc/nginx/conf.d/htpasswd;\r\nadd_header 'Docker-Distribution-Api-Version' 'registry/2.0' always;\r\n\r\n```\r\n~                                                                       \r\n                                                                                                                             90,0-1       底端\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/docker/distribution/issues/comments/143299784","html_url":"https://github.com/docker/distribution/issues/1021#issuecomment-143299784","issue_url":"https://api.github.com/repos/docker/distribution/issues/1021","id":143299784,"user":{"login":"dmp42","id":332946,"avatar_url":"https://avatars.githubusercontent.com/u/332946?v=3","gravatar_id":"","url":"https://api.github.com/users/dmp42","html_url":"https://github.com/dmp42","followers_url":"https://api.github.com/users/dmp42/followers","following_url":"https://api.github.com/users/dmp42/following{/other_user}","gists_url":"https://api.github.com/users/dmp42/gists{/gist_id}","starred_url":"https://api.github.com/users/dmp42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmp42/subscriptions","organizations_url":"https://api.github.com/users/dmp42/orgs","repos_url":"https://api.github.com/users/dmp42/repos","events_url":"https://api.github.com/users/dmp42/events{/privacy}","received_events_url":"https://api.github.com/users/dmp42/received_events","type":"User","site_admin":false},"created_at":"2015-09-25T17:43:41Z","updated_at":"2015-09-25T17:43:41Z","body":"You are using self-signed certificates?\r\n\r\nAgain, I would really encourage you to start simple, by following *strictly* the documentation, without any additions - and looking into your docker daemon logs."}}