A Raspberry Pi proxy server allows you to control the websites that people can visit. It can also remove trackers and other unwanted junk from these web pages. Follow these simple steps to set it up.
Privoxy Proxy server
A web proxy sits between the computers in your network and the internet. Proxy intercepts HTTP and HTTPS traffic and acts as a border controller. It checks the URL (or URL) that someone is trying to access, and if it is in the list of banned or matches any of the banned criteria, the proxy connection is denied.
If the proxy is happy with the website, it downloads the web page and forwards it to the computer that requested it. This provides some degree of anonymity for the devices in your network.
Proxy refreshes the web pages it downloads. All tracking scripts, ads or other unwanted material are removed, so that you only get a clean web page. The hidden payload with snooping and privacy-intrusive cruft that often accompanies a visit to a website is removed. It̵7;s like a sheep dip for web pages.
Of course, ad blocking is a controversial topic. Much of the content that you access freely on the web is only available due to advertising funding. From a privacy point of view, the tracking and cross-correlation between everything you do on the internet is scary at best and invasive at worst.
Privoxy (the proxy that improves privacy) allows you to avoid much of it. Because it is centrally managed, it is also easy to administer. Once you have set up the browser on the various machines in your network to use the proxy, all administration is performed on the proxy, rather than on individual devices.
To install a Privoxy, make an SSH connection to your Raspberry Pi. The IP address of our test device is 192.168.4.18, so we write the following:
We will be installing new software on a Raspberry Pi, so it is a good idea to update the archive indexes and install all available updates. We can perform both of these tasks with a single command that uses
&& to chain two
apt-get commands in succession. The second command only runs if the first one ends without error.
We write the following:
sudo apt-get update && sudo apt-get upgrade
Depending on the vintage of your Raspberry Pi and when you last updated it, it may take some time. When done, we install Privoxy:
sudo apt-get install privoxy
By default, Privoxy accepts HTTP and HTTPS connections from the computer it is running on. We have to tell you to accept connections from any other computer we decide to point to. The Privoxy configuration file is located at: “/ etc / privoxy / config.” We must use
sudo to write changes in it.
Our command is:
sudo nano /etc/privoxy/config
The configuration file is very long. However, the bulk of the file consists of comments and instructions. Scroll down until you see the beginning of section 4.2.
We are looking for
listen-address settings. Comment on the two original commands by placing a number sign (
#) at the beginning of the line and then add the following new entry:
This instructs Privoxy to accept connections on port
8118 from any IP address. Privoxy runs with a set of filters applied to URLs through a set of rules called actions. You can edit filters and actions such as text files or use the Privoxy browser interface to make changes.
The administrator account on Privoxy is not password protected, so you need to consider whether you want this feature enabled on your network. If you do, scroll to the bottom of the file and type this line:
To save your changes, press
Enterand then press
Ctrl+X to close the editor.
We now 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 no error messages. Let’s try a remote administrative connection from the browser Open a browser on another computer and then browse to the IP address of your Raspberry Pi on port 8118.
In our example, this is:
You should see the Privoxy website, which is shown below.
This means that Privoxy runs and works with its default settings. The default values have been carefully selected, and in most cases they will fit well.
Now we need to tell the browsers on all the computers in your network to use Privoxy as a proxy server.
Configure your browser
With any browser, you can use proxy settings. The “Help” function in a browser shows you how to do this. In Firefox, just type “about: preferences” in the address bar.
Scroll to the “Network Settings” section, and then click “Settings.”
Under “Configure proxy access to the Internet”, select the radio button next to the “Manual proxy configuration” option. Enter the IP address of your Raspberry Pi in the “HTTP Proxy” address field, then type “8118” in the “Port” field.
Select the checkbox next to the “Also use this proxy for FTP and HTTPS” option (the “HHTPS Proxy” and “FTP Proxy” fields will be filled in for you) and then click “OK” at the bottom.
Close the configuration tabs and open a website – it should appear as usual without any problems. If so, Privoxy is running its default settings.
Open a web browser and go to config.privoxy.org.
Click “View and change current configuration” on Privoxy’s website. The configuration overview page allows you to see the configuration of actions and filters.
You can edit the files directly in an editor (the file paths are on the screen). It is much easier to use the configuration features of the browser interface. Note that by design you can not edit the settings for “default.action”.
Click “Edit” to open the “Match-All.Action” settings.
The editing options are displayed. Clicking on any of the light blue text opens a link to a help page that describes that item.
The “Set to Caution”, “Set to Medium” and “Set to Advanced” buttons will increase or decrease the mildness of Privoxy with its filtration. You can turn up Privoxy’s paranoia setting so that it aggressively filters everything that is even a little suspicious. Or you can relax and let it work with moderate confidence.
Click “Edit” to adjust all parameters individually.
Click the radio buttons next to each radio to “Enabled,” “Disabled,” or “No change.”
The “Description” column provides a brief explanation of each setting. But if you click on one of the links in the “Action” column, you can check out the entire “Help” page for that item.
To save your settings, click “Submit” at the top or bottom of the page.
Try the default settings first
The default settings should work well in most cases. But if you want to adjust a setting for any particular reason, Privoxy gives you all the options you need.
Before making any changes, however, you can make a copy of the plain text settings files. This allows you to easily reverse what you did if you are locked out of the browser interface.