I am currently trying to configuring nexus3 as private registry for docker images with nginx serving as a reverse proxy . Created 3 repos within nexus namely NexusDockerProxy(docker proxy), NexusDockerHosted(docker hosted,http port:4444) & NexusDockerGroup(docker group,http port:5555) with both the hosted and proxy added.
The nexus is configured with nginx where we are using a self signed certificate and have added the same to nginx configuration file .
server {
proxy_send_timeout 120;
proxy_read_timeout 300;
proxy_buffering off;
tcp_nodelay on;
server_tokens off;
client_max_body_size 1G;
listen 80;
server_name server908.int.org.com;
location / {
rewrite ^(.*) https://server908.int.org.com$1 permanent;
}
}
server {
listen 443;
server_name server908.int.org.com;
keepalive_timeout 60;
ssl on;
ssl_certificate /etc/ssl/certs/orgnexus.crt;
ssl_certificate_key /etc/ssl/certs/orgnexus.key;
ssl_ciphers HIGH:!kEDH:!ADH:!MD5:@STRENGTH;
ssl_session_cache shared:TLSSSL:16m;
ssl_session_timeout 10m;
ssl_prefer_server_ciphers on;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto "https";
proxy_pass http://server908.int.org.com:8082;
proxy_read_timeout 90;
}
}
# correlates to your nexus http connector
server {
listen 6666;
server_name server908.int.org.com;
keepalive_timeout 60;
ssl on;
ssl_certificate /etc/ssl/certs/orgnexus.crt;
ssl_certificate_key /etc/ssl/certs/orgnexus.key;
ssl_ciphers HIGH:!kEDH:!ADH:!MD5:@STRENGTH;
ssl_session_cache shared:TLSSSL:16m;
ssl_session_timeout 10m;
ssl_prefer_server_ciphers on;
client_max_body_size 1G;
chunked_transfer_encoding on;
location / {
access_log /var/log/nginx/docker.log;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto "https";
#proxy_pass http://server908.int.org.com:4444;
proxy_pass http://server908.int.org.com:5555;
proxy_read_timeout 90;
}
}
We have commented below entries with “/etc/default/docker” file .
http_proxy=http://x.x.x.x:3128
https_proxy=http://x.x.x.x:3128
Login is successful too
[root@server446 ~]$ docker login -u admin -p admin123 server908.int.org.com:6666
Login Succeeded
Search for images too works fine .
[dockertest@server446 ~]$ docker search server908.int.org.com:6666/fedora
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
org.com server908.int.org.com:6666/fedora Official Docker builds of Fedora 544 [OK]
org.com server908.int.org.com:6666/fedora/apache 33 [OK]
org.com server908.int.org.com:6666/fedora/couchdb 32 [OK]
org.com server908.int.org.com:6666/fedora/firefox 23 [OK]
org.com server908.int.org.com:6666/fedora/mariadb 23 [OK]
org.com server908.int.org.com:6666/fedora/qpid 20 [OK]
org.com server908.int.org.com:6666/fedora/redis 20 [OK]
org.com server908.int.org.com:6666/fedora/ssh 20 [OK]
org.com server908.int.org.com:6666/fedora/nginx 19 [OK]
org.com server908.int.org.com:6666/fedora/memcached 18 [OK]
org.com server908.int.org.com:6666/fedora/rabbitmq 18 [OK]
org.com server908.int.org.com:6666/fedora/earthquake 17 [OK]
org.com server908.int.org.com:6666/fedora/nodejs 15 [OK]
org.com server908.int.org.com:6666/mattsch/fedora-nzbhydra Fedora NZBHydra 4 [OK]
org.com server908.int.org.com:6666/dockingbay/fedora-rust Trusted build of Rust programming language... 3 [OK]
org.com server908.int.org.com:6666/gluster/gluster-fedora Official GlusterFS image [ Fedora ( latest... 3 [OK]
org.com server908.int.org.com:6666/startx/fedora Simple container used for all startx based... 3 [OK]
org.com server908.int.org.com:6666/eminguez/flexget-fedora Flexget Docker Container based in Fedora t... 2 [OK]
org.com server908.int.org.com:6666/eminguez/transmission-fedora Transmission Fedora (fedora:latest) docker... 2 [OK]
org.com server908.int.org.com:6666/fedora/owncloud 2 [OK]
org.com server908.int.org.com:6666/gdepuille/fedora-ansible Image to test Ansible playbook with Fedora 2 [OK]
org.com server908.int.org.com:6666/kumarpraveen/fedora-sshd Fedora docker file for ssh service which m... 2 [OK]
org.com server908.int.org.com:6666/vbatts/fedora-varnish https://github.com/vbatts/laughing-octo/tr... 2 [OK]
org.com server908.int.org.com:6666/darksheer/fedora Hourly update latest Fedora Image 1 [OK]
org.com server908.int.org.com:6666/darksheer/fedora22 Base Fedora 22 Image -- Updated hourly
1 [OK]
But we face below issue while trying to pull images .
[dockertest@server446 ~]$ docker pull server908.int.org.com:6666/fedora
Using default tag: latest
Trying to pull repository server908.int.org.com:6666/fedora ...
latest: Pulling from server908.int.org.com:6666/fedora
691bc14ee274: Pulling fs layer
error pulling image configuration: unknown blob
With nexus logs I see below certification error.
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:387) [na:1.8.0_91]
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292) [na:1.8.0_91]
at sun.security.validator.Validator.validate(Validator.java:260) [na:1.8.0_91]
at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324) [na:1.8.0_91]
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229) [na:1.8.0_91]
Not sure what certificate is it looking for and where
Also with push we get 404 error as below .
[dockertest@server446 ~]$ docker push server908.int.org.com:6666/maven:1
The push refers to a repository [server908.int.org.com:6666/maven]
701925f78142: Layer already exists
78bb4fee972f: Layer already exists
e1300844f726: Layer already exists
bfee0515af91: Preparing
2afcf4c557eb: Preparing
72cfa243711c: Waiting
9bf603e17b04: Waiting
70b22baddf90: Waiting
596ecbaf3ba4: Waiting
445ed6ee6867: Waiting
c59fa6cbcbd9: Waiting
8d4d1ab5ff74: Waiting
error parsing HTTP 404 response body: invalid character '<' looking for beginning of value:
When proxy_pass set to “http://server908.int.org.com:4444” i.e. NexusDockerHosted(docker hosted, http port:4444, we are able to login,push and pull with nexus but not able to pull fresh image from internet docker hub. We get below error with it.
[root@server446 ~]$ docker pull server908.int.org.com:6666/centos
Using default tag: latest
Trying to pull repository server908.int.org.com:6666/centos ...
manifest unknown: manifest unknown
The nexus documentaion is not providing any clear instructions over the same. Am I missing something important within nginx or docker or nexus. I am referring below references.
https://stackoverflow.com/questions/39148462/docker-login-not-working-with-nexus-3-private-registry
Nexus3 Documentation for Docker Hosting
Any help to get docker pull would be highly helpful thanks.
2
Answers
I am able to pull the images with a minor tweak done within nexus . Following below link allowed me to search and pull the unavailable images within nexus from docker hub.
https://support.sonatype.com/hc/en-us/articles/213464948-How-to-trust-the-SSL-certificate-issued-by-the-HTTP-proxy-server-in-Nexus
I don’t believe Nexus is a pull through cache. You would pull from the hub directly. You can then tag your image and push it to your local registry of you want it there.