Skip to content

Gitlab ssl_certificate

Summary

I recently installed gitlab on debian, running an existing webserver with apache. Now I'm trying to make apache and nginx run alongside eachother. When starting the gitlab server with sudo gitlab-ctl start and tailing it, I'm getting this error:

nginx: [emerg] no "ssl_certificate" is defined for the "listen ... ssl" directive in /var/opt/gitlab/nginx/conf/gitlab-http.conf:34

/etc/gitlab/gitlab.rb

external_url "https://gitlab.domain.com:8090"
registry_external_url "https://registry.domain.com:8090"
nginx['redirect_http_to_https'] = true
nginx['listen_port'] = 8080
nginx['listen_https'] = 8090
nginx['redirect_http_to_https_port'] = 8090
nginx['ssl_certificate'] = "/etc/letsencrypt/live/gitlab.domain.com/fullchain.pem"
nginx['ssl_certificate_key'] = "/etc/letsencrypt/live/gitlab.domain.com/privkey.pem"
nginx['custom_gitlab_server_config'] = "location ^~ /.well-known { root /var/www/letsencrypt; }"
letsencrypt['enable'] = true
letsencrypt['contact_emails'] = ['email@email.com']
registry_nginx['redirect_http_to_https'] = true
mattermost_nginx['redirect_http_to_https'] = true

I have a domain that only supports Https, so I can't access the site without the ssl configuration. Setting up gitlab I used this tutorial: https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-gitlab-on-debian-9. I added the allow rule through ufw for the ports 8080 and 8090, created the certificates using sudo certbot -d gitlab.domain.com.

Steps to reproduce

  • Install apache2 and setup default http redirect to https
  • Install gitlab through the tutorial
  • Add config to /etc/gitlab/gitlab.rb
  • create certificates with sudo certbot -d gitlab.domain.com --email email@email.com
  • Run sudo gitlab-ctl stop && sudo gitlab-ctl reconfigure && sudo gitlab-ctl start

What is the current bug behavior?

URL not accessible and nginx creating the error nginx: [emerg] no "ssl_certificate" is defined for the "listen ... ssl" directive in /var/opt/gitlab/nginx/conf/gitlab-http.conf:34

What is the expected correct behavior?

No errors and gitlab accessible through the gitlab.domain.com url

Relevant logs and/or screenshots

gitlab-ctl tail-output

==> /var/log/gitlab/nginx/current <==
2020-02-11_11:45:31.37029 nginx: [emerg] no "ssl_certificate" is defined for the "listen ... ssl" directive in /var/opt/gitlab/nginx/conf/gitlab-http.conf:34

==> /var/log/gitlab/nginx/error.log <==
2020/02/11 11:45:31 [emerg] 24461#0: no "ssl_certificate" is defined for the "listen ... ssl" directive in /var/opt/gitlab/nginx/conf/gitlab-http.conf:34

==> /var/log/gitlab/nginx/current <==
2020-02-11_11:45:32.43052 nginx: [emerg] no "ssl_certificate" is defined for the "listen ... ssl" directive in /var/opt/gitlab/nginx/conf/gitlab-http.conf:34

==> /var/log/gitlab/nginx/error.log <==
2020/02/11 11:45:32 [emerg] 24462#0: no "ssl_certificate" is defined for the "listen ... ssl" directive in /var/opt/gitlab/nginx/conf/gitlab-http.conf:34

Results of GitLab environment info

Expand for output related to GitLab environment info

sudo gitlab-rake gitlab:env:info

System:         Debian 10
Current User:   git
Using RVM:      no
Ruby Version:   2.6.5p114
Gem Version:    2.7.10
Bundler Version:1.17.3
Rake Version:   12.3.3
Redis Version:  5.0.7
Git Version:    2.24.1
Sidekiq Version:5.2.7
Go Version:     unknown

GitLab information
Version:        12.7.5
Revision:       b0fe37ef58e
Directory:      /opt/gitlab/embedded/service/gitlab-rails
DB Adapter:     PostgreSQL
DB Version:     10.9
URL:            https://gitlab.domain.com:8090
HTTP Clone URL: https://gitlab.domain.com:8090/some-group/some-project.git
SSH Clone URL:  git@gitlab.domain.com:some-group/some-project.git
Using LDAP:     no
Using Omniauth: yes
Omniauth Providers:

GitLab Shell
Version:        11.0.0
Repository storage paths:
- default:      /var/opt/gitlab/git-data/repositories
GitLab Shell path:              /opt/gitlab/embedded/service/gitlab-shell
Git:            /opt/gitlab/embedded/bin/git

Results of GitLab application Check

Expand for output related to the GitLab application check

sudo gitlab-rake gitlab:check SANITIZE=true

Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 11.0.0 ? ... OK (11.0.0)
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Internal API available: OK
Redis available via internal API: OK
gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes
Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab App ...

Git configured correctly? ... yes
Database config exists? ... yes
All migrations up? ... yes
Database contains orphaned GroupMembers? ... no
GitLab config exists? ... yes
GitLab config up to date? ... yes
Log directory writable? ... yes
Tmp directory writable? ... yes
Uploads directory exists? ... yes
Uploads directory has correct permissions? ... yes
Uploads directory tmp has correct permissions? ... skipped (no tmp uploads folder yet)
Init script exists? ... skipped (omnibus-gitlab has no init script)
Init script up-to-date? ... skipped (omnibus-gitlab has no init script)
Projects have namespace: ... can't check, you have no projects
Redis version >= 2.8.0? ... yes
Ruby version >= 2.5.3 ? ... yes (2.6.5)
Git version >= 2.22.0 ? ... yes (2.24.1)
Git user has default SSH configuration? ... yes
Active users: ... 2
Is authorized keys file accessible? ... yes

Checking GitLab App ... Finished


Checking GitLab subtasks ... Finished

Possible fixes

(If you can, link to the line of code that might be responsible for the problem)