Environment Variables and sudo
export HTTPS_PROXY=http://proxy:3128 works for your commands, but sudo apt update ignores the proxy. Why?
export HTTPS_PROXY=http://proxy:3128
sudo apt update
Choose one answer
Root is never allowed to use a proxy.
apt only reads proxy settings from /etc/hosts, never from the environment.
/etc/hosts
Exported variables expire after one command.
sudo resets the environment and drops your variables.