I know how to configure APT to use a web proxy. But what about snap?
6 Answers
A system option was added in snap 2.28 to specify the proxy server.
$ sudo snap set system proxy.http="http://<proxy_addr>:<proxy_port>"
$ sudo snap set system proxy.https="http://<proxy_addr>:<proxy_port>"
It works on Ubuntu LTS 14.04 and newer.
- 2,927
- 5
- 35
- 47
- 1,496
snapd reads /etc/environment, so setting the usual proxy environment variables there works. On Ubuntu, that's done automatically for you by Settings → Network → Network proxy, so as long as you restart snapd after changing that file you should be set.
- 10,130
There is another way to add environment variables to systemd services:
Create a folder for the snap daemon and create configuration files for the environment variables:
$ sudo mkdir -p /etc/systemd/system/snapd.service.d/
$ echo -e '[Service]\nEnvironment="http_proxy=http://1.2.3.4:3128/"' \
| sudo tee /etc/systemd/system/snapd.service.d/http-proxy.conf
$ echo -e '[Service]\nEnvironment="https_proxy=http://1.2.3.4:3128/"' \
| sudo tee /etc/systemd/system/snapd.service.d/https-proxy.conf
$ sudo systemctl daemon-reload
$ sudo systemctl restart snapd
After that you can check if the environment variables are set for snapd:
$ systemctl show snapd | grep proxy
Environment=http_proxy=http://1.2.3.4:3128/ https_proxy=http://1.2.3.4:3128/
DropInPaths=/etc/systemd/system/snapd.service.d/http-proxy.conf /etc/systemd/system/snapd.service.d/https-proxy.conf
- 4,111
Snap service is configured to use special environment file, so you can just add http_proxy variable to it if your current environment variables are not picked up by the snap.
Open file:
sudo vim /etc/sysconfig/snapd
Add:
http_proxy=http://127.0.0.1:3128
https_proxy=http://127.0.0.1:3128
- 135
Be careful, because the snapd reads the /etc/environment file instead of get the ENV variable. This example below doesn't work:
export https_proxy=http://<your.ip.here>:3128
you have to use:
http://<your.ip.here>:3128