Search code examples
dockernginxnexussonatypedebian-7.6.0

Unable to connect docker login to nexus repo behind nginx


I have a computer trying to do:

docker login docker-repo.mydomain.com

docker-repo is handled by an nginx which has this config:

   server {
      listen 80;
      server_name docker-repo.mydomain.com ;
      # Redirect non-https traffic to https
      return 301 https://$host$request_uri;
    }

    server {
      listen 443 ssl http2;
      server_name docker-repo.mydomain.com;
      ssl_certificate /etc/nginx/ssl/docker-repo.mydomain.com.crt;
      ssl_certificate_key /etc/nginx/ssl/docker-repo.mydomain.key;
      server_tokens off;
      ssl_dhparam /etc/nginx/ssl/dhparams.pem;
      ssl_session_cache shared:SSL:10m;
      ssl_protocols TLSv1.2;
      ssl_prefer_server_ciphers on;
      ssl_ciphers 'ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-CAMELLIA256-SHA:AES256-GCM-S$

      gzip_proxied any;
      gzip on;
      gzip_min_length 1023;
      gzip_types text/plain text/css text/js text/javascript text/xml application/json application/javascript application/x-javascript application/xml application/xml+rss;
      proxy_send_timeout        610s;
      proxy_read_timeout        610s;
      proxy_max_temp_file_size  16384m;
      proxy_redirect            off;
      proxy_buffers             32 4k;
      send_timeout              610s;
      client_max_body_size      0;
      client_body_buffer_size   128k;


      location / {
        proxy_pass http://nexus.mydomain.com:8102;
        proxy_set_header X-Custom-Referrer "https://docker-repo.mydomain.com:443";
        proxy_set_header Host $http_host;
        proxy_set_header Client-IP $remote_addr;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      }

    }

And on nexus.mydomain.com i have sonatype nexus running a docker group with Http Proxy set to run on port 8102

Errors i'm getting:

$ docker login docker-repo.mydomain.com
Username: XXXX
Password:
Error response from daemon: Get https://docker-repo.mydomain.com/v2/: Service Unavailable

If i try to access the page https://docker-repo.mydomain.com from a browser I get the page: HTTP Error 400, Not a docker request

I i try to ping both docker-repo and nexus.mydomain.com it works fine.


Solution

  • Turns out that this was due to a proxy i was behind. Once i added the proxy config with the proper exclusions it worked fine.