Use HTTP Clients with SOCKS Proxies (or SSH Tunnels) on GNU/Linux

Last updated on July 30, 2020

On GNU/Linux, it is easy to create SOCKS proxies using programs such as ssh or tor. However, many applications on GNU/Linux, such as LibreOffice and genymotion (up to the date on which this post is written), can be configured to directly use HTTP proxies (or web proxies), but not SOCKS proxies. In this post, we will use privoxy, a non-cache web proxy, to enable these applications to use SOCKS proxies.

First, we need to install privoxy. This can be done by using one of the following commands:

  • Debian/Ubuntu: sudo apt-get install privoxy
  • Fedora/RHEL/CentOS: sudo dnf install privoxy or sudo yum install privoxy

Then, we need to configure privoxy by editing /etc/privoxy/config:

sudo nano /etc/privoxy/config

Here, you can replace nano with your favorite editor. Assuming that a SOCKS proxy is available at localhost on port 12345 (e.g., started by ssh -D 12345 remote-host), append

forward-socks5 / localhost:12345 .

to the end of this file. (Certainly, you should replace localhost:12345 with your targeted SOCKS proxy). This will set privoxy to convert all HTTP traffic into localhost:8118 to SOCKS 5 traffic into localhost:12345. To use SOCKS 4, replace forward-socks5 with forward-socks4. For more details, check out the privoxy manual.

Next, we need to start privoxy (or restart if privoxy has already been started). To do this, run

sudo systemctl reload-or-restart privoxy

To always start privoxy upon system startup, run

sudo systemctl enable privoxy

Now you should be able to configure applications to use the targeted SOCKS proxy (localhost:12345 in our example) by setting localhost:8118 as their HTTP proxy.

Related: SOCKS proxy versus HTTP proxy

3 thoughts on “Use HTTP Clients with SOCKS Proxies (or SSH Tunnels) on GNU/Linux

  1. Pingback: SOCKS proxy versus HTTP proxy - Real Residential Proxies Reviews

  2. Pingback: Using HTTP clients with (SOCKS) proxies or (SSH) tunnels | 0ddn1x: tricks with *nix

  3. Pingback: Links 20/8/2017: KStars 2.8.1, Fedora Design Interns | Techrights

Leave a Reply

Your email address will not be published.