0

We am trying to get nexus via nginx reverse proxy working as a private registry for docker images. We are able to perform all the operations such as pull,search and tag but not able to push to nexus registry .

Below is the nginx configuration under location block.

 location ~ ^/(v1|v2)/ { 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:5555; proxy_read_timeout 90; } 

We are able to search and pull images.

x.x.x.x - admin [23/Jun/2017:14:31:20 +0800] "GET /v1/search?q=fedora&n=25 HTTP/1.1" 200 3733 "-" "docker/1.12.6 go/go1.7.4 kernel/3.10.0-514.10.2.el7.x86_64 os/linux arch/amd64 UpstreamClient(Docker-Client/1.12.6 \x5C(linux\x5C))" 

x.x.x.x - admin [23/Jun/2017:14:31:39 +0800] "GET /v2/fedora/apache/manifests/latest HTTP/1.1" 200 1362 "-" "docker/1.12.6 go/go1.7.4 kernel/3.10.0-514.10.2.el7.x86_64 os/linux arch/amd64 UpstreamClient(Docker-Client/1.12.6 \x5C(linux\x5C))" x.x.x.x - admin [23/Jun/2017:14:31:40 +0800] "GET /v2/fedora/apache/manifests/sha256:8531786520bb57b155bbb39d3c670dceab554b9c4ccdb556ccfbe89b23df414c HTTP/1.1" 200 1362 "-" "docker/1.12.6 go/go1.7.4 kernel/3.10.0-514.10.2.el7.x86_64 os/linux arch/amd64 UpstreamClient(Docker-Client/1.12.6 \x5C(linux\x5C))" x.x.x.x - admin [23/Jun/2017:14:31:40 +0800] "GET /v2/fedora/apache/blobs/sha256:c786010769a8fc7975e72c2b78f902425a6387fb5dda8852b3be2849e979e290 HTTP/1.1" 200 4094 "-" "docker/1.12.6 go/go1.7.4 kernel/3.10.0-514.10.2.el7.x86_64 os/linux arch/amd64 UpstreamClient(Docker-Client/1.12.6 \x5C(linux\x5C))" x.x.x.x - admin [23/Jun/2017:14:31:40 +0800] "GET /v2/fedora/apache/blobs/sha256:4e81794d88f1b28cc1653df183400d08647143123a3f141fc8cab7cd97fc75e3 HTTP/1.1" 200 294 "-" "docker/1.12.6 go/go1.7.4 kernel/3.10.0-514.10.2.el7.x86_64 os/linux arch/amd64 UpstreamClient(Docker-Client/1.12.6 \x5C(linux\x5C))" x.x.x.x - admin [23/Jun/2017:14:31:40 +0800] "GET /v2/fedora/apache/blobs/sha256:40da690b349860b5b2cf7cee231c21a04f1461a77ee542b77a2345412f521ae0 HTTP/1.1" 200 183 "-" "docker/1.12.6 go/go1.7.4 kernel/3.10.0-514.10.2.el7.x86_64 os/linux arch/amd64 UpstreamClient(Docker-Client/1.12.6 \x5C(linux\x5C))" x.x.x.x - admin [23/Jun/2017:14:31:40 +0800] "GET /v2/fedora/apache/blobs/sha256:ebb42f0b0e1ad2d2ae815a6615b95bb59b925710df3db4b8fdb2f9fdaa14a806 HTTP/1.1" 200 294 "-" "docker/1.12.6 go/go1.7.4 kernel/3.10.0-514.10.2.el7.x86_64 os/linux arch/amd64 UpstreamClient(Docker-Client/1.12.6 \x5C(linux\x5C))" x.x.x.x - admin [23/Jun/2017:14:31:42 +0800] "GET /v2/fedora/apache/blobs/sha256:8eea4f8b1da3e8c0848778a69e4ee73ad474a7be35fcc5ce7784a0b64ce711a7 HTTP/1.1" 200 57816237 "-" "docker/1.12.6 go/go1.7.4 kernel/3.10.0-514.10.2.el7.x86_64 os/linux arch/amd64 UpstreamClient(Docker-Client/1.12.6 \x5C(linux\x5C))" 

But with push we face below error.

x.x.x.x - admin [23/Jun/2017:14:32:34 +0800] "POST /v2/fedora/apache/blobs/uploads/?from=fedora%2Fssh&mount=sha256%3Aacd6cf67daf4cd1fcff55ece5a906a45e1569b81271b80136a1f5fecfa4546ed HTTP/1.1" 404 717 "-" "docker/1.12.6 go/go1.7.4 kernel/3.10.0-514.10.2.el7.x86_64 os/linux arch/amd64 UpstreamClient(Docker-Client/1.12.6 \x5C(linux\x5C))" 

when we try with proxy _pass url as http://server908.int.org.com:4444, we are able to push but cant pull the images .

Is it possible in nginx to pass two different proxy_pass urls under the same location but for different request methods . Any help would be really great ..Thanks

1

2 Answers 2

1

With Nginx you can catch the method used in the request.

So you just have to make some adjustements for redirect on the right proxy.

location /blabla { if ($request_method = POST ) { # Proxy for POST } if ($request_method = GET ) { # Proxy for GET } 
2
  • Thanks . Your solution helped me in getting it to work with minor tweaks . I have mentioned it in my answer Commented Jun 29, 2017 at 7:05
  • @Alim So vote up the answer, that's how this site works. Commented Jun 29, 2017 at 7:09
0

Its working now with below location configuration.

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; if ($request_method !~* GET) { proxy_pass http://server908.int.org.com:4444; } if ($request_method = GET) { proxy_pass http://server908.int.org.com:5555; } proxy_read_timeout 90; } 

Thanks for your help

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.