Setting up a Proxy on Raspberry Pi
Introduction
The Raspberry Pi is a compact computer that can be used as a proxy server for a home network or as a proxy client for IoT devices.
Basic Setup
Raspberry Pi as a Client
Proxy configuration in /etc/environment:
export http_proxy=http://proxy_ip:port
export https_proxy=http://proxy_ip:port
export no_proxy=localhost,127.0.0.1
Raspberry Pi as a Proxy Server
Installing Squid:
sudo apt install squid
Editing /etc/squid/squid.conf:
http_port 3128
acl localnet src 192.168.1.0/24
http_access allow localnet
Starting: sudo systemctl start squid
Now, devices on the network can use the Raspberry Pi as a proxy on port 3128.
Raspberry Pi as a Proxy Gateway
Configure iptables for transparent proxying of all traffic through the Raspberry Pi for devices on your home network.
Advanced Configuration
Environment Variables
Most tools support standard environment variables for proxies:
- HTTP_PROXY / http_proxy — proxy for HTTP requests
- HTTPS_PROXY / https_proxy — proxy for HTTPS requests
- NO_PROXY / no_proxy — list of exclusions (addresses that bypass the proxy)
- ALL_PROXY / all_proxy — proxy for all protocols
SSL and Self-Signed Certificates
Corporate proxies often use their own SSL certificates. To work through them, you need to:
1. Obtain the proxy's CA certificate from the administrator
2. Add it to the system certificate store
3. Or disable SSL verification (for testing only)
Authentication
Two main authentication methods are supported:
By username and password — standard HTTP Basic authentication. Credentials are sent with each request. URL format: http://user:pass@proxy_ip:port
By IP address (whitelist) — your IP is added to a whitelist. No credentials need to be sent.
Verification
After configuration, verify:
1. Perform a test request through the proxy
2. Ensure the IP address has changed
3. Check connection speed
4. Ensure there are no DNS leaks
Troubleshooting
Proxy Not Connecting
- Check the correctness of the address and port
- Ensure the firewall is not blocking the connection
- Check proxy accessibility from your network
SSL Errors
- For corporate proxies, add the CA certificate
- For testing, temporarily disable SSL verification
- Update SSL libraries to the latest version
Authentication Errors
- Check username and password
- Ensure the correct credentials format
- Try encoding special characters in the password (URL encoding)
Best Practices
- Use environment variables — for flexibility and security
- Do not hardcode credentials — use environment variables or configuration files
- Configure exclusions — do not proxy localhost and internal addresses
- Document settings — in the project's README or team wiki
- Test after changes — any configuration change requires verification
Conclusion
Proper proxy configuration ensures stable tool operation and connection security. Follow the recommendations in this guide and always verify functionality after setup.