This article will be interesting for those who didn't know it already -- you can turn any Linux computer into a SOCKS5 (and SOCKS4) proxy in just one command:
ssh -N -D 0.0.0.0:1080 localhost
And it doesn't require root privileges. The ssh command starts up dynamic
-D port forwarding on port 1080 and talks to the clients via SOCSK5 or SOCKS4 protocols, just like a regular SOCKS5 proxy would! The -N option makes sure ssh stays idle and doesn't execute any commands on localhost.
If you also wish the command to go into background as a daemon, then add -f option:
ssh -f -N -D 0.0.0.0:1080 localhost To use it, just make your software use SOCKS5 proxy on your Linux computer's IP, port 1080, and you're done, all your requests now get proxied.
Access control can be implemented via iptables. For example, to allow only people from the ip 188.8.131.52 to use the SOCKS5 proxy, add the following iptables rules:
iptables -A INPUT --src 184.108.40.206 -p tcp --dport 1080 -j ACCEPT iptables -A INPUT -p tcp --dport 1080 -j REJECT The first rule says, allow anyone from 220.127.116.11 to connect to port 1080, and the other rule says, deny everyone else from connecting to port 1080.
Surely, executing iptables requires root privileges. If you don't have root privileges, and you don't want to leave your proxy open (and you really don't want to do that), you'll have to use some kind of a simple TCP proxy wrapper to do access control.