-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Gitlab Registry port and host clarification #1118
Comments
So if I use nginx-proxy with the letsencrypt companion, I cannot get the registry to work? |
What nginx-proxy do you use ? |
I'm using https://github.com/jwilder/nginx-proxy and https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion I got it to work now. For future reference I will leave my config here:
|
A confusing solution @Pegasuz - The Gitlab container registry is internal to Gitlab. In your solution you are enabling the internal registry AND creating a defacto registry using the official docker registry container. Which one is actually answering? Looks like it's the docker registry and not the Gitlab registry. |
This is what it's confusing : there is NO gitlab registry, it's only an authentification service. As I explain in my comment, look at the schema on this page : https://docs.docker.com/registry/spec/auth/token/ |
Yep. This is true. |
But GitLab calls it GitLab Container Registry. |
@xxorax is correct. This is why an external docker registry is needed. Hence my setup. |
@Pegasuz any chance of you sharing your full docker-compose setup (minus anything sensitive, obviously)? I'm having some trouble with the same setup as yours (nginx-proxy, letsencrypt, registry & gitlab). Thanks in advance! |
@niksubramanian Here you go:
|
hey @Pegasuz, how do you get the cert for the registry in the right folder? Do you map your letsencrypt container in the gitlab cert folder? thx in advance |
@xxorax I also use my custom nginx proxy. Could you help me clarify two things?
|
Ok, I've managed it. @solidnerd I think, the manual is missing a clear example for how to set up the registry if you already have a Nginx as reverse proxy. How about adding the following to the documenation: Setting up the Registry with Your Own Secured NginxIf you already have a Nginx server as reverse proxy and manage your own certififcates there (e.g. with Letsencrypt) the setup can be simplified. We assume the following URLs for your Gitlab installation and your registry respectively:
1. Create auth tokensThe details entered during the creation process (domain name, etc.) are irrelevant:
2. Update docker-compose.ymlFirst add the configuration for the registry container to your registry:
image: registry:2.6.2
restart: unless-stopped
expose:
- "5000"
ports:
- "5000:5000"
volumes:
- ./gitlab/shared/registry:/registry
- ./certs:/certs
environment:
- REGISTRY_LOG_LEVEL=info
- REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY=/registry
- REGISTRY_AUTH_TOKEN_REALM=https://git.example.de/jwt/auth
- REGISTRY_AUTH_TOKEN_SERVICE=container_registry
- REGISTRY_AUTH_TOKEN_ISSUER=gitlab-issuer
- REGISTRY_AUTH_TOKEN_ROOTCERTBUNDLE=/certs/registry.crt
- REGISTRY_STORAGE_DELETE_ENABLED=true Then update the gitlab:
environment:
# ...
# Registry
- GITLAB_REGISTRY_ENABLED=true
- GITLAB_REGISTRY_HOST=registry.example.de
- GITLAB_REGISTRY_PORT=443
- GITLAB_REGISTRY_API_URL=http://registry:5000
- GITLAB_REGISTRY_KEY_PATH=/certs/registry.key
volumes:
- ./gitlab:/home/git/data
- ./certs:/certs 3. Nginx site configurationserver {
root /dev/null;
server_name registry.example.de;
charset UTF-8;
access_log /var/log/nginx/registry.example.de.access.log;
error_log /var/log/nginx/registry.example.de.error.log;
# Set up SSL only connections:
listen *:443 ssl http2;
ssl_certificate /etc/letsencrypt/live/registry.example.de/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/registry.example.de/privkey.pem;
ssl_ciphers 'ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4';
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_session_timeout 5m;
client_max_body_size 0;
chunked_transfer_encoding on;
location / {
proxy_set_header Host $http_host; # required for docker client's sake
proxy_set_header X-Real-IP $remote_addr; # pass on real client's IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 900;
proxy_pass http://localhost:5000;
}
}
server {
listen *:80;
server_name registry.example.com;
server_tokens off; ## Don't show the nginx version number, a security best practice
return 301 https://$http_host:$request_uri;
} |
@mikehaertl Feel free to make a PR for your last entry. I think would be nice for everyone else who need this. After this I think we can close this issue. |
…-setup Issue #1118 Update docs for registry container
Issue #1118 Fix hostname inconsistency
This issue has been automatically marked as stale because it has not had any activity for the last 60 days. It will be closed if no further activity occurs during the next 7 days. Thank you for your contributions. |
I spend a lot of time to understand why I cannot contact to the Gitlab Registry (defined by $GITLAB_REGISTRY_HOST:$GITLAB_REGISTRY_PORT). I did not defined SSL_REGISTRY_CERT_PATH and SSL_REGISTRY_KEY_PATH, because I'm running behind an external proxy which handle HTTPS.
So in this case, you only have to proxy to the Docker Registry (port 5000, from the registry:2 docker image), and so the GITLAB_REGISTRY_HOST and GITLAB_REGISTRY_PORT is only here to inform the gitlab users what is the Docker Registry domain..
I thing this should be mentioned somewhere, like "You can connect to the Docker Registry directly if you handle SSL yourself, and so these param only define the Docker Registry endpoint in the registry tab of a Gitlab project. When you will try to connect to the Docker Registry, it will tell your docker to connect to the Gitlab JWT auth service to get authenticated".
Actualy, even the Gitlab offical doc is very confuse : does Gitlab have it own Registry-app which is proxy the Docker Registry ? No : it's just a simple proxy defined in nginx.
So there is no difference between
docker login registry.gitlab.example.com
anddocker login registry:5000
except that you expect to have SSL enabled on registry.gitlab.example.com (because proxied by nginx with ssl).In fact there is no difference with the schema of the offical doc except this nginx proxy to add SSL over the registry.
And so you could even set the domain name of the registry as the same as the gitlab domain (gitlab.example.com) if you handle correctly the request in your proxy (for example by detecting ^/v2 in the request, or/and the docker user-agent string).
The text was updated successfully, but these errors were encountered: