http works just fine
HTTP should not work, see "Redirect HTTP requests to HTTPS"
By default, when you specify an
external_urlstarting with 'https', NGINX will no longer listen for unencrypted HTTP traffic on port 80.
If you want to redirect all HTTP traffic to HTTPS you can use theredirect_http_to_httpssetting.
external_url "https://gitlab.example.com"
nginx['redirect_http_to_https'] = true
So double-check your gitlab.rb, then sudo gitlab-ctl reconfigure
HTTP to HTTPS redirection with Docker Compose
Gitlab-ce docker container unaccessable over https - Stack Overflow
dockerfile - Redirect HTTP TO HTTPS for custom HTTPS port for Omnisus Gitlab with Docker Compose - Stack Overflow
nginx - Install gitlab in one VM with docker-compose having a proxy adding https in another vm - Unix & Linux Stack Exchange
I think you are missing the nginx config in your docker-compose.yml.
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://gitlab.example.com'
nginx['listen_port'] = 80
nginx['listen_https'] = false
nginx['proxy_set_headers'] = {
"X-Forwarded-Proto" => "https",
"X-Forwarded-Ssl" => "on"
}
The following gist helped me a lot! https://gist.github.com/netdesk/c1db2985b542f9916995139318e5a7ce
I had the same problem and solved it by running GitLab docker on a custom HTTP port.
docker-compose.yaml:
web:
image: 'gitlab/gitlab-ee:latest'
restart: always
hostname: 'git.example.com'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://git.example.com'
gitlab_rails['gitlab_shell_ssh_port'] = 2224
nginx['listen_port'] = 8929
nginx['listen_https'] = false
ports:
- '8929:8929'
- '2224:22'
Nginx config:
server {
server_name git.example.com;
location / {
proxy_pass http://localhost:8929;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/git.example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/git.example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
Can someone give a hand and help properly configure container registry in Gitlab? I'm trying to use it with self signed certificates on localhost, used tons of different script to generate *.crt and *.key but nothing seem to work and I can't log in to the registry:
docker login localhost:5005 gives me certificate errors:
Error response from daemon: Get https://localhost:5005/v2/: x509: certificate signed by unknown authority.
I've also tried to copy generated certificate and move it to:
/etc/docker/certs.d/localhost:5005/ca.cert /etc/docker/certs.d/localhost:5005/ca.key
Restarted docker service after with: sudo service docker restart
I've also added insecure registry entry to:
/etc/default/docker DOCKER_OPTS="--insecure-registry localhost:5005"
Above error seem common error but I googled tons of different threads and nothing seem to work. Below docker-compose file I use to spin it up:
version: '3.7'
services:
web:
image: 'gitlab/gitlab-ce:latest'
restart: always
hostname: 'localhost'
container_name: gitlab-ce
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://localhost'
registry_external_url 'https://localhost:5005'
gitlab_rails['lfs_enabled'] = true
gitlab_rails['gitlab_shell_ssh_port'] = 2222
registry_nginx['enable'] = true
registry_nginx['listen_port'] = 5005
registry_nginx['redirect_http_to_https'] = true
registry_nginx['ssl_certificate'] = "/ssl_certs/localhost.crt"
registry_nginx['ssl_certificate_key'] = "/ssl_certs/localhost.key"
ports:
- '8084:80'
- '8443:443'
- '2222:22'
- '5005:5005'
volumes:
- './vol/config:/etc/gitlab'
- './vol/logs:/var/log/gitlab'
- './vol/data:/var/opt/gitlab'
- './vol/ssl_certs:/ssl_certs'
networks:
- gitlab
gitlab-runner:
image: gitlab/gitlab-runner:alpine
container_name: gitlab-runner
restart: always
depends_on:
- web
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- './vol/gitlab-runner:/etc/gitlab-runner'
networks:
- gitlab
networks:
gitlab:
name: gitlab-networkScript to generate my certificates:
#!/usr/bin/env bash # Set the TLD domain we want to use BASE_DOMAIN="localhost" # Days for the cert to live DAYS=1095 # A blank passphrase PASSPHRASE="" # Generated configuration file CONFIG_FILE="config.txt" cat > $CONFIG_FILE <<-EOF [req] default_bits = 2048 prompt = no default_md = sha256 x509_extensions = v3_req distinguished_name = dn [dn] C = CA ST = BC L = Vancouver O = Example Corp OU = Testing Domain emailAddress = webmaster@$BASE_DOMAIN CN = $BASE_DOMAIN [v3_req] subjectAltName = @alt_names [alt_names] DNS.1 = *.$BASE_DOMAIN DNS.2 = $BASE_DOMAIN EOF # The file name can be anything FILE_NAME=$BASE_DOMAIN echo "Generating certs for $BASE_DOMAIN" # Generate our Private Key, CSR and Certificate # Use SHA-2 as SHA-1 is unsupported from Jan 1, 2017 openssl req -new -x509 -newkey rsa:2048 -sha256 -nodes -keyout "$FILE_NAME.key" -days $DAYS -out "$FILE_NAME.crt" -passin pass:$PASSPHRASE -config "$CONFIG_FILE" # OPTIONAL - write an info to see the details of the generated crt openssl x509 -noout -fingerprint -text < "$FILE_NAME.crt" > "$FILE_NAME.info" # Protect the key chmod 400 "$FILE_NAME.key"
EDIT:
I finally found working configuration:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://gitlab.gitlabenv.com:8443'
registry_external_url 'https://registry.gitlabenv.com:5005'
gitlab_rails['time_zone'] = 'America/Chicago'
gitlab_rails['gitlab_shell_ssh_port'] = 2222
gitlab_rails['lfs_enabled'] = true
registry_nginx['enable'] = true
registry_nginx['ssl_certificate'] = "/etc/ssl/certs/gitlab/server-cert.pem"
registry_nginx['ssl_certificate_key'] = "/etc/ssl/certs/gitlab/server-key.pem"
nginx['listen_port'] = 443
nginx['redirect_http_to_https'] = true
nginx['ssl_certificate'] = "/etc/ssl/certs/gitlab/server-cert.pem"
nginx['ssl_certificate_key'] = "/etc/ssl/certs/gitlab/server-key.pem"