I've set up a nexus docker registry with the proxy type. And I put the registry behind an Nginx reverse proxy as follow:
file registry.example.com.conf
:
upstream nexus {
server 127.0.0.1:8080;
}
proxy_send_timeout 120;
proxy_read_timeout 300;
proxy_buffering off;
proxy_request_buffering off;
server {
server_name registry.example.com.conf;
client_max_body_size 1G;
location / {
proxy_pass http://nexus/;
proxy_set_header Host $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";
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.com.conf/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com.conf/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = registry.example.com.conf) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name registry.example.com.conf;
return 404; # managed by Certbot
}
For pull requests it's ok and works fine. I can pull images from registry.example.com.conf
and if it does not exist, it'll pull it from the hub.docker.com
. but when I want to put images to registry.example.com.conf
I get:
5216338b40a7: Layer already exists
error parsing HTTP 404 response body: unexpected end of JSON input: ""
And I think it's because of the proxy type of my registry in nexus. I should create another registry in nexus with the type of hosted I think. But its subdomain also should be different from the proxy type (ex. registry2.example.com). So when I want to push an image I shoud tage it with registry2 and when I want to pull it I should get with registry. How can I setup the nginx to support both pull and push requests of docker within the same domain? I also read this code but it is not complete and correct