I know how to configure APT to use a web proxy. But what about snap?
7 Answers
A system option was added in snap 2.28 to specify the proxy server.
$ sudo snap set system proxy.http=""
$ sudo snap set system proxy.https="" 7 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.
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="' \ | sudo tee /etc/systemd/system/snapd.service.d/http-proxy.conf
$ echo -e '[Service]\nEnvironment="https_proxy="' \ | sudo tee /etc/systemd/system/snapd.service.d/https-proxy.conf
$ sudo systemctl daemon-reload
$ sudo systemctl restart snapdAfter that you can check if the environment variables are set for snapd:
$ systemctl show snapd | grep proxy Environment=http_proxy= https_proxy= DropInPaths=/etc/systemd/system/snapd.service.d/http-proxy.conf /etc/systemd/system/snapd.service.d/https-proxy.conf Snap uses snapd daemon. You only need to define http_proxy and https_proxy in /etc/environment and restart the service: systemctl restart snapd.
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/snapdAdd:
http_proxy=
https_proxy= 2 There is a reported bug:
Please subscribe to check changes on it.
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=you have to use: