I have a gitlab instance with a public IP set up and running. However, trying to add a gitlab-runner fails, because the reverse lookup for the runner does not seem to work as intended. When registering the runner, I can see an incoming POST request with HTTP status 200 on nginx on the gitlab instance
1.2.3.4 - - [09/Oct/2021:21:41:51 +0200] "POST /api/v4/runners HTTP/1.1" 200 179 "-" "gitlab-runner 14.3.2 (14-3-stable; go1.13.8; linux/amd64)"
but the runner registration fails.
sudo gitlab-runner --debug register --non-interactive --url https://gitlab.example.org/ --registration-token asdasdasdasd --executor shell --tag-list shared --run-untagged=true --locked=false --access-level=not_protected
Runtime platform arch=amd64 os=linux pid=2488 revision=e0218c92 version=14.3.2
Checking runtime mode GOOS=linux uid=0
Running in system-mode.
Dialing: tcp gitlab.example.org:443 ...
ERROR: Registering runner... failed runner=LQ_-Gq-k status=200 OK
PANIC: Failed to register the runner. You may be having network problems.
The message is a bit misleading…
How to show what happens in gitlab after the connection was made? I mean the HTTP response is officially a 200.
The runner runs behind a NAT and has no public IP, but the gitlab instance has. The route and DNS settings are working to be able to resolve the runner.
2
Answers
Gitlab runs behind an Nginx reverse proxy, but the proxy is not controlled by
gitlab-ctl
. Since this was a fresh install, I checked my vhost definition and figured that it may be the case, because the incoming requests to register seemed to be eaten by nginx somehow.gitlab-ctl tail
did not even log the incoming request to register the runner.With that assumption, I enabled the nginx shipped with gitlab in
gitlab.rb
and ran
gitlab-ctl reconfigure
just to disable nginx ingitlab.rb
afterwardsand run
gitlab-ctl reconfigure
again.After that procedure, nginx configs are in
/var/opt/gitlab/nginx/conf/
. I replaced my vhost definition withgitlab-http.conf
and adapted it further.Now it all works as intended. My vhost template was completely outdated.
I use the ddns, so that you need to resolve the domain name by editing the hosts file, in my case is ubuntu:
add the ip address of your gitlab server ip, like this:
then, execute the gitlab-runner register again, it should be successful.