Home > Software design >  Gitlab runner connection refused. Proxy not working
Gitlab runner connection refused. Proxy not working

Time:07-17

I have a gitlab runner that is on a server needing a proxy to access external sites.

In my systemd setting, I have:

[Service]
Environment="HTTP_PROXY=http://squidproxy.example.com:3128/"
Environment="HTTPS_PROXY=http://squidproxy.example.com:3128/"
Environment="NO_PROXY=gitlab.example.com"

But I still can't access pip. I receive this in the build log

WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f10bd297880>: Failed to establish a new connection: [Errno 111] Connection refused')': /simple/virtualenv/

I am believe my proxy isn't used in the builds.

CodePudding user response:

Your proxy won't be used in the builds unless you add the proxy to docker containers

In your config.toml for your runners add:

[[runners]]
  environment = ["https_proxy=http://squidproxy.example.com:3128", "http_proxy=http://squidproxy.example.com:3128", "HTTPS_PROXY=squidproxy.example.com:3128", "HTTP_PROXY=squidproxy.example.com:3128", "no_proxy=gitlab.example.com", "NO_PROXY=gitlab.example.com"]

If you needed a proxy to reach your gitlab server you would have a config like this:

[[runners]]
pre_clone_script = "git config --global http.proxy $HTTP_PROXY; git config --global https.proxy $HTTPS_PROXY"
environment = ["https_proxy=http://squidproxy.example.com:3128", "http_proxy=http://squidproxy.example.com:3128", "HTTPS_PROXY=squidproxy.example.com:3128", "HTTP_PROXY=squidproxy.example.com:3128"]

CodePudding user response:

In the job that requires an internet connection set these variables:

internet-job:
  variables:
    https_proxy: http://abc.de
    http_proxy: http://abc.de
    no_proxy: http://abc.de

Or even set them on the top-level if you want all jobs to have them per default.

Reference: https://docs.gitlab.com/ee/ci/yaml/#variables

  • Related