Search code examples
sshgoogle-cloud-platformgoogle-compute-enginesocks

Privoxy + socks5 tunnel on remote host


I'd like to run privoxy on a remote machine to remove adds when I browse the web from my laptop. My plan is to use socks5 tunnel from my local machine, pointing to an instance hosted in Google Cloud.

ssh -D 1080 -fCNq [email protected]

I have configured macOS to use 127.0.0.1:1080 as the socks proxy successfully and can access the internet. So far so good. I've also installed privoxy on the server and started it on 127.0.0.1:8118.

sudo yum install privoxy -y
sudo service privoxy start

However, I can't figure out how to connect my tunneled traffic to privoxy. How do I get all new connections after the socks connection on the server to go through privoxy?


Solution

  • Here's my suggestion.

    1. On remotemachine, run privoxy listening on 127.0.0.1:8118, just as you describe.

    2. On localmachine, run a command like the following. Authenticate as you normally would, either via password or via ssh key. (If at some point you decide that you want to do it without human intervention, you may need to use a passphraseless key, perhaps under a user created just for this purpose.) (Note that the localhost in the below refers to localhost from remotemachine's point of view!)

      ssh -vnNf -L 1080:localhost:8118 remotemachine

    3. Configure your browser on localmachine to use localhost:1080 as a socks proxy.

    4. PROFIT

    I'm pretty sure this will do the trick, but if I'm missing something please let me know and I'll try to figure it out/fix it.