- Pull and Run the Squid Container Run the following command in your terminal. This uses the popular ubuntu/squid image.
docker run -d --name squid-local -e 'TZ=UTC' -p 3128:3128 ubuntu/squid:latest-d: Runs in detached mode (background).
-p 3128:3128: Maps port 3128 on your machine to port 3128 in the container (Squid's default port).
- Verify it is Running Check the logs to ensure it started correctly: Bash
docker logs squid-local
Method 2: Direct Installation (Linux/Ubuntu)
-
Configure Access (Crucial Step) By default, Squid denies most traffic. For local testing, you usually need to allow your local IP range.
Open the config file: sudo nano /etc/squid/squid.conf add the following line to the squid proxy conf
acl allowed_http_sites dstdom_regex -i (^|\.)huggingface\.coFind the line http_access allow localhost (it usually exists by default).
If you want to allow any device on your local network (be careful with this in production), add this line above any deny all rules: Plaintext
http_access allow all
Save and exit (Ctrl+O, Enter, Ctrl+X).
-
Restart Squid Apply the changes: Bash
sudo systemctl restart squid
Method 3: Direct Installation (macOS)
If you are on a Mac, use Homebrew:
Install: brew install squid
Start Service: brew services start squid
Config Location: /usr/local/etc/squid.conf (Intel) or /opt/homebrew/etc/squid.conf (Apple Silicon).
How to Test Your Proxy
Once Squid is running (via Docker or Local Install), test it using curl.
- Check your IP without the proxy: Bash
Result: You should see your actual public IP.
- Check your IP through the proxy: Bash
curl -x http://localhost:3128 http://httpbin.org/ip
Result: If successful, you will still see your IP (Squid is transparent by default), but the request went through the proxy.
-
Check the Access Logs To confirm the traffic actually hit Squid, check the access logs.
Docker: docker exec -it squid-local tail -f /var/log/squid/access.log
Linux: sudo tail -f /var/log/squid/access.log
You should see an entry for TCP_MISS/200 or TCP_TUNNEL/200 corresponding to your