While Squid primarily functions as an HTTP caching proxy, it can be compiled with SOCKS5 support through specific compilation flags. The official Squid FAQ mentions this capability, but the instructions require deeper technical interpretation for practical implementation.
Ensure you have these packages installed on your Linux system:
sudo apt-get install build-essential libssl-dev libsocks5-dev
For existing Squid source code, you'll need to modify the compilation process:
./configure CFLAGS="-Dbind=SOCKSbind" LDFLAGS="-lsocks5"
make
sudo make install
After compilation, add these lines to your squid.conf:
# SOCKS5 specific configurations
socks5_proxy on
socks5_bind 0.0.0.0 port=1080
socks5_protocol socks5
Test your SOCKS5 proxy with curl:
curl --socks5-hostname localhost:1080 https://example.com
If you encounter linking errors during compilation, ensure:
- The libsocks5-dev package is properly installed
- Your LDFLAGS point to the correct library location
- No previous Squid installations conflict with the new build
Remember that Squid's primary optimization is for HTTP traffic. For heavy SOCKS5 usage, monitor:
squidclient mgr:info | grep socks
This will show SOCKS-specific performance metrics.
Squid's default HTTP proxy configuration leaves many developers needing SOCKS5 support for more flexible networking scenarios. While the official FAQ mentions SOCKS5 capability, the compilation instructions remain cryptic for those unfamiliar with C/C++ build systems.
Before proceeding, ensure you have:
- Squid source code (version 3.5 or later recommended)
- Development tools (gcc, make, autoconf)
- libsocks5 or similar SOCKS library installed
- Root/sudo access for system-wide installation
Here's the complete process to compile Squid with SOCKS5 support:
# First, clean any previous builds
make distclean
# Configure with SOCKS5 flags
./configure \
--prefix=/usr/local/squid \
--enable-ssl \
--enable-icap-client \
CFLAGS="-Dbind=SOCKSbind" \
LIBS="-lsocks5"
# Compile and install
make -j$(nproc)
sudo make install
After installation, modify your squid.conf:
# Enable SOCKS protocol
http_port 3128
socks_port 1080
# SOCKS-specific ACLs
acl socks_protocol proto SOCKS
http_access allow socks_protocol
Test your setup with curl:
curl --socks5-hostname localhost:1080 http://example.com
For persistent SOCKS connections, consider adding these to squid.conf:
# SOCKS connection persistence
socks_persistent_connection on
socks_max_connection_timeout 300
If you encounter linking errors during compilation:
# Check library paths
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
# Re-run configure with explicit library path
./configure LDFLAGS="-L/usr/local/lib" ...
For connection timeouts, verify firewall rules and increase timeout values:
socks_connect_timeout 60
socks_io_timeout 120