How to use a Raspberry Pi as a proxy server (with Privoxy)

A Raspberry Pi and its official raspberry logo.
The Raspberry Pi Foundation

A Raspberry Pi proxy server allows you to control the websites that people can visit. You can also remove trackers and other unwanted junk from those web pages. Follow these simple steps to set it up.

The Privoxy proxy server

A web proxy sits between the computers on your network and the Internet. The proxy intercepts HTTP and HTTPS traffic, acting as a border control officer. It checks the web address (or URL) someone is trying to access, and if it is on the banned list or matches any of the banned criteria, the proxy rejects the connection.

If the proxy is satisfied with the website, it retrieves the web page and forwards it to the computer that requested it. This provides a degree of anonymity for the devices on your network.

The proxy records the web pages it retrieves. All tracking scripts, advertisements, or other unwanted material are removed, so you only get a clean web page. The hidden burden of spying and invasion of privacy that often accompanies a website visit is removed. It’s like a sheep sauce for web pages.

Of course, ad blocking is a controversial topic. Much of the content that you freely access on the web is only available due to ad funding. However, from a privacy standpoint, tracking and cross-correlating everything you do on the internet is creepy at best and invasive at worst.

Privoxy (the privacy-enhancing proxy) allows you to bypass a lot of that. Because it is centrally managed, it is also easy to manage. Once you have configured the browser on the various machines on your network to use the proxy, all administration is done on the proxy, rather than on individual devices.

Privoxy Installation

To install a Privoxy, make an SSH connection to your Raspberry Pi. The IP address of our test unit is 192.168.4.18, so we write the following:

ssh pi@192.168.4.18

We are installing new software on a Raspberry Pi, so it is a good idea to update the repository indexes and install any available updates. We can perform both tasks with a single command that uses && chain two apt-get commands sequentially. The second command will only be executed if the first one completes without errors.

We write the following:

sudo apt-get update && sudo apt-get upgrade

Depending on how old your Raspberry Pi is and when you last updated it, this may take a little time. When complete, we install Privoxy:

sudo apt-get install privoxy

Accept connections

By default, Privoxy will accept HTTP and HTTPS connections from the computer it is running on. We need to tell it to accept connections from any other computer we decide to target. The Privoxy configuration file is located at: “/ etc / privoxy / config”. We will need to use sudo write changes to it.

Our command is:

sudo nano /etc/privoxy/config

The configuration file is very long. However, most of the file is made up of comments and instructions. Scroll down until you see the beginning of section 4.2.

We are looking for the listen-address settings. Comment out the two original commands by placing a pound sign (#) at the beginning of the line, and then add the following new entry:

listen-address :8118

This instructs Privoxy to accept connections on the port. 8118 from any IP address. Privoxy runs using a set of filters that are applied to URLs through a set of rules called actions. You can edit the filters and actions as text files or use the Privoxy browser interface to make changes.

The administrator account on Privoxy is not password protected, so you should consider whether you want this feature to be enabled on your network. If it does, scroll to the bottom of the file and type this line:

enable-edit-actions 1

To save your changes, press Ctrl+O, Enterand then press Ctrl+X to close the editor.

Now we need to restart Privoxy for the changes to take effect:

sudo systemctl restart privoxy

We can use systemctl to verify that Privoxy is running and see its status:

sudo systemctl status privoxy

We have green lights and there are no error messages. Let’s try a remote administrative connection from a browser. Open a browser on another computer, and then look for the IP address of your Raspberry Pi on port 8118.

In our example, this is:

192.168.4.18:8118

You should see the Privoxy home page, as shown below.

The Privoxy home page in a browser.

This means that Privoxy is up and running with its default settings. The defaults have been carefully chosen and will fit well in most cases.

Now, we must tell the browsers of all the computers on your network to use Privoxy as their proxy server.

Configuring your browser

All browsers allow you to use proxy settings. The “Help” function within a browser will show you how to do this. In Firefox, just type “about: preferences” in the address bar.

Scroll down to the “Network Settings” section and then click “Settings.”

Click "Settings" in it "Network Configuration" section in Firefox.

Under “Configure Internet Proxy Access”, select the radio button next to “Manual Proxy Configuration” option. Type the IP address of your Raspberry Pi in the “HTTP Proxy” address field and then type “8118” in the “Port” field.

Select the check box next to the “Also use this proxy for FTP and HTTPS” option (the “HHTPS Proxy” and “FTP Proxy” fields will be filled in automatically), and then click “OK” at the bottom.

The "Configure proxy access to the Internet" options in Firefox.

Close the configuration tabs and open a website; it should appear as usual with no problems. If so, Privoxy is working with its default settings.

Privoxy Configuration

Open a browser and go to config.privoxy.org.

The Privoxy home page in a browser window.

Click “View and change current settings” on the Privoxy home page. The configuration summary page allows you to view the action and filter settings.

You can edit the files directly in an editor (file paths are provided on screen). It is much easier to use the configuration capabilities of the browser interface. Note that, by design, you cannot edit the “default action” settings.

Click “Edit” to open the “Match-All.Action” settings.

Click "Edit" in the Privoxy configuration window.

The editing options appear. Clicking on any of the light blue text will open a link to a help page that describes that item.

The buttons “Set to cautious”, “Set to medium” and “Set to advanced” will increase or decrease the tolerance of Privoxy with its filtering. It can increase Privoxy’s paranoia settings, so it aggressively filters out anything that is mildly suspicious. Or you can relax it and let it function with a moderate degree of confidence.

Click “Edit” to adjust each of the parameters individually.

Click "Edit" in it "Match-All.Action" page in Firefox to adjust the parameters.

Click the radio buttons next to each option for “Enabled,” “Disabled,” or “No Changes.”

The “Description” column provides a brief explanation for each setting. However, if you click on any of the links in the “Action” column, you can see a complete “Help” page for that item.

The Privoxy granular configuration page in Firefox.

To save your settings, click “Submit” at the top or bottom of the page.

Try the defaults first

The default settings should work fine in most cases. However, if you want to modify a setting for any particular reason, Privoxy gives you all the options you need.

However, before making any changes, you may want to make a copy of the plain text configuration files. This will allow you to easily reverse what you did if you cannot access the browser interface.

Leave a Reply