To route system-wide traffic through Proxy server (
http://squid.cs.ait.ac.th:3128),you need to configure environment variables, the APT package manager, and optionally Docker.
1.Configure System-Wide Environment Variables:
Edit the global environment file so all terminal sessions and system processes use the proxy.
Open the file in a text editor:
Bash
sudo nano /etc/environment
Add the following lines at the bottom:
Bash
HTTP_PROXY="http://squid.cs.ait.ac.th:3128/"
HTTPS_PROXY="http://squid.cs.ait.ac.th:3128/"
http_proxy="http://squid.cs.ait.ac.th:3128/"
https_proxy="http://squid.cs.ait.ac.th:3128/"
NO_PROXY="localhost,127.0.0.1,::1"
no_proxy="localhost,127.0.0.1,::1"
Save and exit (
Ctrl+O, Enter, then Ctrl+X), then apply the changes to your current session:Bash
source /etc/environment
2.Configure APT Package Manager:
APT does not automatically use system environment variables, so it requires its own configuration file.
Create a new APT configuration file:
Bash
sudo nano /etc/apt/apt.conf.d/99proxy
Paste the following configuration:
Plaintext
Acquire::http::Proxy "http://squid.cs.ait.ac.th:3128/";
Acquire::https::Proxy "http://squid.cs.ait.ac.th:3128/";
Save and exit, then verify by running
sudo apt update.3.Configure Docker Daemon Proxy (Optional):
If you are running Docker containers, configure the systemd service override for Docker.
Create a configuration directory for the Docker service:
Bash
sudo mkdir -p /etc/systemd/system/docker.service.d
Create the proxy configuration file:
Bash
sudo nano /etc/systemd/system/docker.service.d/http-proxy.conf
Add your configuration:
Ini, TOML
[Service]
Environment="HTTP_PROXY=http://squid.cs.ait.ac.th:3128"
Environment="HTTPS_PROXY=http://squid.cs.ait.ac.th:3128"
Environment="NO_PROXY=localhost,127.0.0.1,::1"
Reload systemd and restart Docker to apply:
Bash
sudo systemctl daemon-reload
sudo systemctl restart docker