Edit .profile file (with vi or nano)
nano .profile
And add following lines:
export http_proxy=http://127.0.0.1:8888/
export https_proxy=http://127.0.0.1:8888/
And run:
source .profile
Edit apt config file for proxy:
nano /etc/apt/apt.conf.d/proxy.conf
And Add following lines:
Acquire::http::Proxy "http://127.0.0.1:8888/";
Acquire::https::Proxy "http://127.0.0.1:8888/";
Create service and config file:
mkdir -p /etc/systemd/system/docker.service.d
nano /etc/systemd/system/docker.service.d/proxy.conf
Add following config:
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:8888/"
Environment="HTTPS_PROXY=http://127.0.0.1:8888/"
Environment="NO_PROXY=localhost,127.0.0.1,.local"
Reload and run it:
systemctl daemon-reload
systemctl restart docker.service
systemctl status docker.service
Edit k3s service env file:
nano /etc/systemd/system/k3s.service.env
And add following line:
HTTP_PROXY=http://127.0.0.1:8888/
HTTPS_PROXY=http://127.0.0.1:8888/
NO_PROXY="localhost,127.0.0.1,0.0.0.0,10.0.0.0/8,cattle-system.svc,192.168.10.0/24,.svc,.cluster.local,example.com"
Create service and config file:
mkdir /etc/systemd/system/gitlab-runner.service.d
nano /etc/systemd/system/gitlab-runner.service.d/http-proxy.conf
Add following config:
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:8888/"
Environment="HTTPS_PROXY=http://127.0.0.1:8888/"
Reload and run it:
systemctl daemon-reload
systemctl restart gitlab-runner
systemctl status gitlab-runner
systemctl show --property=Environment gitlab-runner
Note: Adding proxy to docker containers should be done after registration runners Adding proxy inside gilab runner:
nano /etc/gitlab-runner/config.toml
And and the following config into every single section [[runners]]_section
:
pre_get_sources_script = "git config --global http.proxy $HTTP_PROXY; git config --global https.proxy $HTTPS_PROXY"
environment = ["https_proxy=http://127.0.0.1:8888", "http_proxy=http://127.0.0.1:8888", "HTTPS_PROXY=127.0.0.1:8888", "HTTP_PROXY=127.0.0.1:8888"]
It consider your http proxy is run on the "127.0.0.1:8888", you should replace it with your proxy address.