flytreeleft / nexus3-keycloak-plugin

Sonatype Nexus plugin for Keycloak integration
Apache License 2.0
107 stars 81 forks source link

Docker hosted registry login #26

Closed myukselen closed 5 years ago

myukselen commented 5 years ago

I have tried your 0.3.3-SNAPSHOT version on sonatype nexus3 3.18.1.

When I want to do docker login for docker hosted repository, it gives this error:

Error response from daemon: login attempt to https://nexus.example.com/v2/ failed with status: 404 Not Found

With bare image from sonatype, I can login successfully. With only change being your plugin, I am suspicious if plugin breaks some functionality necessary for docker repositories.

I would be glad to give further details if you are interested in investigating.

flytreeleft commented 5 years ago

@myukselen Yes, please paste the Nexus3 logs and maybe the logs and configurations of the reverse gateway.

myukselen commented 5 years ago

Thanks for your prompt reply, here you can find the files.

Image is started by

docker run -t --name nexus-logger -p 8081:8081 -p 5000:5000 -e NEXUS_CONTEXT=/ -e JAVA_MAX_MEM=4096M --network=nexus3_net myukselen/nexus3:3.18.1-01

nexus.log nginx_docker.log nginx-site-nexus3.txt

flytreeleft commented 5 years ago

@myukselen Thanks, I will check it. It may take some time, please be patient. :)

flytreeleft commented 5 years ago

@myukselen Try to change

server {
    # ...
    location / {
        if ($http_user_agent ~ docker ) {
            proxy_pass      http://127.0.0.1:5000;
        }
        proxy_pass          http://127.0.0.1:8081;
        # ...
    }
}

to

server {
    # ...
    location / {
        set $proxy_target_url http://127.0.0.1:8081;
        if ($http_user_agent ~* "^docker/.+$" ) {
            set $proxy_target_url http://127.0.0.1:5000;
        }
        proxy_pass         $proxy_target_url ;
        # ...
    }
}
myukselen commented 5 years ago

I have changed that part as you requested. But getting same errors. I tried with this command:

docker login nexus.example.com

That is why I have another ssl server on port 5001 that does also reverse proxy to port 5000 only. Same error is displayed with the below command.

docker login nexus.example.com:5001

If your setup is working, I would be glad to try replicate from scratch.

flytreeleft commented 5 years ago

@myukselen Here is an example in https://github.com/flytreeleft/docker-nginx-gateway/blob/master/examples/vhost.d/repo.example.com.conf , you can modify your Nginx configuration following it.

flytreeleft commented 5 years ago

@myukselen I have done some tests, but cannot produce the 404 error.

Please following these:

And paste the Nginx log after running docker login.

myukselen commented 5 years ago

I have made a couple of tests more. May be my docker image on top of sonatype/nexus3 is problemmatic. With 3.18.1 from sonatype I still get 404. That can be caused by some difference between sonatype and cavemandaveman setups. Here is the logs you have requested: docker_err-3.18.1-sonatype.log

Right now, I tried with cavemandaveman images by updating locally. Your plugin works including 3.16.2 for docker login. But when I upgrade to 3.17.0 and above, It starts to give 401 not authorized. Here is the logs for 401: docker_err-3.17-caveman.log

Thanks for your efforts. For 401 case I can open another issue if you like.

flytreeleft commented 5 years ago

@myukselen Sorry, I still can not produce the error with Nexus3 v3.18.0 (whose image is built on develop/cavemandaveman-nexus-docker) :(.

Is it successful that doing docker login without Nginx ?

myukselen commented 5 years ago

I am sorry, what I was having trouble was basing onto sonatype images. With your caveman nexus image build I can login to all versions with your plugin 0.3.3-SNAPSHOT.

The problem is with sonatype image and probably its file permissions inside. I did not investigate further.

Thank you. I am closing this issue as it is working on top of caveman nexus3 images with only docker-hosted repository configured.