Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP Method Options returns 401 #232

Closed
Goldenflamer opened this issue Feb 1, 2022 · 2 comments
Closed

HTTP Method Options returns 401 #232

Goldenflamer opened this issue Feb 1, 2022 · 2 comments
Labels
Related to Docker Registry Issues related to docker registry and not the UI

Comments

@Goldenflamer
Copy link

Goldenflamer commented Feb 1, 2022

Hi, I use this docker registry UI and I have an issue.

Bug description

I am using the official docker registry docker image from dockerhub and connected the docker-registry-ui latest version from dockerhub to it. However, I am using Basic Auth on the docker registry.
While most of the HTTP requests from the docker registry UI to the docker registry work fine, the Basic Auth credentials are NOT included in HTTP requests with the OPTIONS method. However, the docker registry requires authentication even for the method OPTIONS and therefore, a 401 (unauthenticated) error is returned when I try to view the history of an image or when I try to delete an image.

How to Reproduce

For UI bug, steps to reproduce the behavior:

  1. Enable Basic auth on docker registry
  2. Try to delete an image from docker registry via docker registry UI while you are authenticated
  3. Or try to view the history of an image via docker registry UI while you are authenticated

For service bug, steps to reproduce the behavior:

My docker-compose file

version: '3.3'
services:
    docker-registry-ui:
      image: joxit/docker-registry-ui:latest
      ports:
        - 1980:80
      environment:
        - REGISTRY_TITLE=XXXDocker Registry
        - REGISTRY_URL=https://dockerhub.xxx.xxx.com
        - SINGLE_REGISTRY=true
        - SHOW_CONTENT_DIGEST=true
        - DELETE_IMAGES=true
      depends_on:
        - registry
      labels:
        - 'traefik.enable=true'
        - 'traefik.http.routers.registryui.entrypoints=websecure'
        - 'traefik.http.routers.registryui.rule=Host(`hub.xxx.xxx.com`)'
        - 'traefik.http.routers.registryui.tls.certresolver=le'
        - 'traefik.http.routers.registryui.middlewares=authelia@docker'
      networks:
        - web
      
networks:
  web:
    external: true

My private docker registry configuration

version: '3'
services:
  registry:
    image: registry:latest
    restart: always
    ports:
    - "5000:5000"
    environment:
      REGISTRY_AUTH: htpasswd
      REGISTRY_AUTH_HTPASSWD_REALM: Registry-Realm
      REGISTRY_AUTH_HTPASSWD_PATH: /auth/registry.passwd
      REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /data
    volumes:
      - /registry-images:/data
      - /var/data/registry/auth:/auth
    networks:
      - web
    labels:
      - 'traefik.enable=true'
      - 'traefik.http.routers.registry.entrypoints=websecure'
      - 'traefik.http.routers.registry.rule=Host(`dockerhub.xxx.xxx.com`)'
      - 'traefik.http.routers.registry.tls.certresolver=le'
      - 'traefik.http.services.registry.loadbalancer.server.port=5000'
      - 'traefik.http.middlewares.registryheaders.headers.customResponseHeaders.Access-Control-Allow-Origin=https://hub.xxx.xxx.com'
      - 'traefik.http.middlewares.registryheaders.headers.customResponseHeaders.Access-Control-Allow-Methods=*'
      - 'traefik.http.middlewares.registryheaders.headers.customResponseHeaders.Access-Control-Allow-Headers=*'
      - 'traefik.http.middlewares.registryheaders.headers.customResponseHeaders.Access-Control-Allow-Credentials=true'
      - 'traefik.http.middlewares.registryheaders.headers.customResponseHeaders.X-Content-Type-Options=nosniff'
      - 'traefik.http.routers.registry.middlewares=registryheaders@docker'



networks:
  web:
    external: true

Expected behavior

I want to view the history and delete images via the docker registry UI without receiving 401 unauthenticated errors.

System information

  • OS: Ubuntu 20.04 LTS
  • Browser:
    • Name: Chrome
    • Version: 97.0.4692.99 (64 bit)
  • Docker registry UI:
    • Version: 2.1.0
    • Server: docker
- Docker version: 20.10.12
- Docker registry ui tag: latest
- OS/Arch: linux/arm64
- Tools: docker-compose
@Joxit Joxit added the Related to Docker Registry Issues related to docker registry and not the UI label Feb 5, 2022
@Joxit
Copy link
Owner

Joxit commented Feb 5, 2022

Hello,

Thank you for using my project 😄

This is a known docker registry issue, and this is also described in the FAQ

  • Why DELETE fails with 401 status code (using Basic Auth) ?
    • This is caused by a bug in docker registry, I suggest to have your UI on the same domain than your registry and use NGINX_PROXY_PASS_URL e.g. registry.example.com/ui/. (see #104, #204, #207, #214).

Your choices are

  1. Use NGINX_PROXY_PASS_URL
  2. Configure your reverse proxy (traefik) to return 200 instead of 401 on OPTION methods

@Joxit
Copy link
Owner

Joxit commented Mar 13, 2022

I close this issue since this is a docker registry related issue

@Joxit Joxit closed this as completed Mar 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Related to Docker Registry Issues related to docker registry and not the UI
Projects
None yet
Development

No branches or pull requests

2 participants