Raspberry Pi Proxy Server with Privoxy?

A proxy server acts as an intermediary between client devices and the internet. Setting up a Raspberry Pi as a proxy server can provide more private, secure web browsing. The free proxy server software Privoxy filters web page data to improve privacy, remove ads, and modify web page content.

Raspberry Pi Proxy Server with Privoxy?

Requirements

  • Raspberry Pi OS (recommended Raspbian or Raspberry Pi OS Lite)
  • Ethernet cable or WiFi connectivity
  • Keyboard, monitor, mouse (for setup)

Installation Steps

Enable SSH on Raspberry Pi

  1. Insert SD card into computer
  2. Access SD card files
  3. Navigate to boot partition
  4. Create empty file named ssh

Enabling SSH allows remote login to Raspberry Pi for headless setup.

Connect Raspberry Pi to Network

  1. Insert SD card and connect Raspberry Pi to power
  2. Connect Raspberry Pi to router with Ethernet cable or configure WiFi
  3. Find Raspberry Pi IP address on router admin interface

SSH into Raspberry Pi

On computer in same network:

ssh pi@raspberry_pi_ip

Default password is raspberry.

Update Packages

Update packages to latest versions:

sudo apt update

sudo apt full-upgrade

Reboot Raspberry Pi.

Install Privoxy

Install Privoxy proxy server software:

sudo apt install privoxy

Configure Privoxy

  1. Edit Privoxy config file:

sudo nano /etc/privoxy/config

Uncomment/modify following lines:

listen-address  0.0.0.0:8118

forward-socks5t   /               127.0.0.1:9050 .

  1. forward         192.*.*.*/     .

    • Set listen address to 0.0.0.0:8118 for remote access
    • Forward socks to Tor at 127.0.0.1:9050 (optional)
    • Forward local network (modify as needed)
  2. Save and exit config file

Finish Setup

Restart Privoxy to apply config changes:

sudo systemctl restart privoxy

Increase max open files limit for proxy connections:

sudo nano /etc/security/limits.conf

Add:

nofile 65536

Save, exit, and reboot.

The Raspberry Pi Privoxy proxy server is now accessible on your network at IP address port 8118.

Client Proxy Setup

To use the Raspberry Pi as a proxy server, client browser/device proxy settings must be configured:

Browser Setup

Set browser proxy settings:

  • HTTP Proxy: Raspberry Pi IP address
  • Port: 8118

Windows Device Setup

  1. Go to Control Panel > Internet Options
  2. Select the Connections tab
  3. Click LAN Settings
  4. Enable proxy checkbox
  5. Enter proxy IP address and port 8118

Mac Device Setup

  1. Go to System Preferences > Network
  2. Select network service
  3. Go to Proxies tab
  4. Enable proxy checkbox
  5. Enter Raspberry Pi IP address and port 8118

Reboot device for proxy settings to take effect.

Privoxy Actions

Privoxy provides powerful content filtering to improve privacy, security, and remove ads/trackers. Below are some common actions to add to /etc/privoxy/config:

Block ads:

{ +block }

.ad-banner 

.sponsored-links

Remove cookies:

{ -cookie-jar }

.doubleclick.net

Block Facebook tracking:

{ +block }

/Facebook

More Privoxy actions →

Using Squid Proxy

For more features/performance as a caching proxy, Squid can be used instead of Privoxy:

sudo apt install squid

Configure Squid port 8118 in /etc/squid/squid.conf

Privoxy can still filter forward to Squid on 127.0.0.1:8118

This combines caching/performance of Squid with filtering of Privoxy.

Conclusion

Setting up a Raspberry Pi with Privoxy is an easy way to create a privacy focused proxy server for secure web browsing. With additional actions, content can be customized to remove ads and protect from tracking. For improved performance, Squid caching proxy can also be combined with Privoxy filtering.

Key Takeaways

  • Privoxy on Raspberry Pi makes an inexpensive, customizable proxy
  • Client devices routes web traffic to Privoxy for filtering
  • Removes ads, blocks trackers, and modifies web page content
  • Simple headless setup with SSH access to Raspberry Pi
  • Combine with Squid proxy for added caching and speed

Frequently Asked Questions

  1. What are the benefits of a proxy server?
    A proxy server provides security, privacy, and anonymity by hiding client IP address and filtering malicious content. It can also improve speed via caching.

  2. Does Privoxy work on mobile devices?
    Yes, most mobile devices and browsers allow configuring a manual proxy server IP and port to use Privoxy on a Raspberry Pi.

  3. Can you set up multiple Raspberry Pi proxies?
    Yes, you can configure an entire array of Raspberry Pis running Privoxy to balance proxy network traffic.

  4. Is Privoxy better than Squid?
    Privoxy focuses more on filtering web page content, while Squid excels at caching content for faster speeds. Using them together combines these strengths.

  5. Does Privoxy reduce internet speeds?
    Some additional latency can be introduced by evaluating web page contents, but Privoxy aims to minimize impact on speeds. Fine-tuning filters helps optimize performance.

  6. Can Privoxy be used to bypass region restrictions?
    Yes, Privoxy makes it appear the client is accessing the website from the proxy server’s location, allowing access if geo-restrictions are based on IP location.

  7. How do I change the Privoxy listening port?
    Edit the listen-address configuration value in /etc/Privoxy/config to change the port from the default 8118.

  8. Can I install Privoxy on Ubuntu?
    Yes, Privoxy install and configuration steps are the same for Ubuntu and Raspberry Pi OS. Just substitute Ubuntu commands.

  9. What is the best Raspberry Pi OS for a proxy server?
    Raspberry Pi OS Lite is recommended for dedicated proxy use since it avoids unnecessary GUI overhead. Raspbian with desktop can also be used.

  10. How do I optimize Privoxy performance?
    Fine-tuning filters, increasing open files limit, using fast SD card, and combining with Squid cache can optimize Privoxy on a Raspberry Pi.

  11. Can I use a VPN connection with Privoxy?
    Yes, routes can be configured to send VPN client traffic to Privoxy for additional privacy, filtering, and geo-location benefits.

  12. Is Squid better than Nginx for reverse proxy?
    Nginx excels as a fast, lightweight web/SSL reverse proxy. Squid focuses on caching entire pages/objects for improved delivery speed.

  13. What is the difference between Privoxy and Tor?
    Tor provides anonymous routing by encrypting and bouncing traffic through its network. Privoxy has no anonymizing routing and mostly modifies web page content.

  14. How do I configure iptables for Privoxy?
    IPtables policies like rate limiting client IPs, dropping banned IPs, NAT port forwarding, etc can enhance protection and improve performance.

  15. Can Privoxy be used for parental controls?
    Yes, Privoxy actions can filter content based on keywords and URLs to block inappropriate, explicit websites. Custom actions tailored to your requirements can enforce strict controls.

  16. How do I optimize Squid cache performance?
    Enable RAM cache, add fast storage, tune disk cache size, enable Hyper cache peer caching, optimize disk block size, and enable caching of common sites/objects.

  17. What is the difference between Privoxy and Polipo?
    Polipo is smaller and simpler single-threaded proxy software compared to Privoxy. Privoxy offers more advanced filtering capabilities but Polipo may be faster.

  18. Can I use a Raspberry Pi Zero for Privoxy?
    Yes the lower-powered Pi Zero can run Privoxy without issue, just make sure to overclock for improved performance under load. Add external storage for page cache.

  19. How can I manage Privoxy remotely?
    Remote admin options include SSH console access, editing config files directly, or installing web admin console like Pixley. Monitor status via output of sudo systemctl status Privoxy.

  20. How do I configure DNS resolution?
    Set forward-socks5t in Privoxy config to forward DNS requests from clients over Tor network for additional privacy and spoofed DNS resolution.

Leave a Comment