kwk / docker-registry-frontend

Browse and modify your Docker registry in a browser.
https://registry.hub.docker.com/u/konradkleine/docker-registry-frontend/
MIT License
1.67k stars 614 forks source link

Registry Hostname not respected #40

Open en0 opened 9 years ago

en0 commented 9 years ago

While running docker-registry-frontend behind haproxy on the same host as my docker registry, the registry-host:host is not respected on client side requests to the docker registry. This is important for proper routing via haproxy

HAPROXY running on hardware. docker registry running in docker container on 127.0.0.1:5000 docker-registry-frontend running in docker container on 127.0.0.1:5001

HAProxy ACL hdr(host) for dockerregistry.domain.local HAProxy ACL hdr(host) for dockerui.domain.local

docker-registry-frontend client side requests are to /v1/search?= not to dockerregistry.domain.local/v1/search?= as it should be.

My startup options:

sudo docker run \
    -d \
    -e ENV_DOCKER_REGISTRY_HOST=dockerregistry.domain.local \
    -e ENV_DOCKER_REGISTRY_PORT=443 \
    -e ENV_DOCKER_REGISTRY_USE_SSL=1 \
    -p 127.0.0.1:5001:80 \
    konradkleine/docker-registry-frontend
en0 commented 9 years ago

A workaround is to use path_beg in haproxy to host the docker registry frontend on the same url as the docker registry itself.

acl is_repo path_beg /v1
acl is_repo path_beg /v2
kwk commented 9 years ago

You are right, requests are made to the frontend server's /v1/... route (see registry-services.js).

The frontend's Apache Server then routes this request to the registry (see apache-site.conf).

Please see my other comment why we cannot simply forward requests to the registry. To put it short, this would require cross-origin resource sharing (CORS). Not everybody has their registry configured to enable CORS and I don't want to force people to enable it.

I suggest you create a PR where you have an ENV_REGISTRY_SHORTCUT option put it in start-apache.sh that shortcuts the path

Browser <-> Apache <-> Registry

to

Browser <-> Registry.

Sound good?

en0 commented 9 years ago

This did help, Thank you @kwk. I appreciate your follow-up.