Deploying Privoxy
Introduction
Privoxy is a non-caching web proxy with advanced filtering capabilities for enhancing privacy, modifying web page data, managing cookies, controlling access, and removing ads and other obnoxious internet junk. Privoxy has a flexible configuration and can be customized to suit individual needs and tastes.
Originally based on Internet Junkbuster, Privoxy has evolved into a powerful privacy tool that works on virtually all web browsers and operating systems. It can be used standalone or in conjunction with other tools like Tor for enhanced anonymity.
Key highlights of Privoxy:
- Ad Blocking: Remove advertisements and banners from web pages
- Privacy Protection: Strip tracking scripts and cookies
- Content Filtering: Modify web page content on the fly
- Cookie Management: Control which cookies are accepted and sent
- Header Manipulation: Modify HTTP headers to enhance privacy
- HTTPS Inspection: Optional man-in-the-middle for HTTPS filtering
- Tor Integration: Works seamlessly with the Tor network
- Flexible Configuration: Highly customizable through action files
- Open Source: Licensed under GPL
This guide walks through deploying Privoxy on Klutch.sh using Docker.
Why Deploy Privoxy on Klutch.sh
Deploying Privoxy on Klutch.sh provides several advantages:
Simplified Deployment: Klutch.sh automatically detects your Dockerfile and builds Privoxy without complex configuration.
Persistent Storage: Attach persistent volumes for configuration and log files.
Centralized Proxy: Use a single Privoxy instance for multiple devices and users.
Environment Variable Management: Securely store configuration options through Klutch.sh’s environment variable system.
Always-On Availability: Your proxy remains operational 24/7 for consistent privacy protection.
Prerequisites
Before deploying Privoxy on Klutch.sh, ensure you have:
- A Klutch.sh account
- A GitHub account with a repository for your Privoxy configuration
- Basic understanding of web proxies and HTTP
- (Optional) Custom filter rules for your specific needs
Understanding Privoxy Architecture
Privoxy operates as an HTTP proxy between your browser and the internet:
HTTP Proxy: Receives requests from clients and forwards them to destination servers.
Filtering Engine: Applies rules to modify requests and responses.
Action Files: Define what actions to take for specific URLs or patterns.
Filter Files: Contain regex patterns for content modification.
Trust Files: Control which sites are trusted for forwarding.
Preparing Your Repository
Create a GitHub repository containing your Dockerfile and Privoxy configuration.
Repository Structure
privoxy-deploy/├── Dockerfile├── config├── user.action├── user.filter└── .dockerignoreCreating the Dockerfile
Create a Dockerfile in the root of your repository:
FROM alpine:3.19
# Install PrivoxyRUN apk add --no-cache privoxy
# Create directoriesRUN mkdir -p /etc/privoxy /var/log/privoxy
# Copy configuration filesCOPY config /etc/privoxy/configCOPY user.action /etc/privoxy/user.actionCOPY user.filter /etc/privoxy/user.filter
# Set permissionsRUN chown -R privoxy:privoxy /etc/privoxy /var/log/privoxy
# Expose proxy portEXPOSE 8118
# Run PrivoxyUSER privoxyCMD ["privoxy", "--no-daemon", "/etc/privoxy/config"]Creating the config File
Create a config file with your Privoxy configuration:
# Privoxy Configuration
# Listen address and portlisten-address 0.0.0.0:8118
# Enable remote access toggleenable-remote-toggle 1
# Enable remote editing of actionsenable-remote-http-toggle 1
# Enable editing of actions filesenable-edit-actions 1
# User manual locationuser-manual /usr/share/doc/privoxy/user-manual
# Config directoryconfdir /etc/privoxy
# Log directorylogdir /var/log/privoxy
# Action filesactionsfile match-all.actionactionsfile default.actionactionsfile user.action
# Filter filesfilterfile default.filterfilterfile user.filter
# Trust file# trustfile trust
# Log filelogfile privoxy.log
# Debug levels (1=connections, 1024=actions, 4096=content filtering)debug 1debug 1024
# Hostname for error pageshostname privoxy.local
# Buffer limitbuffer-limit 4096
# Enable compressioncompression-level 1
# Forward to Tor (optional, uncomment to enable)# forward-socks5t / 127.0.0.1:9050 .Creating user.action File
Create a user.action file for custom actions:
# User-defined action rules
# Block specific trackers{+block{Known tracker}}.google-analytics.com.doubleclick.net.facebook.com/tr.twitter.com/i/jot
# Block social media widgets{+block{Social media widget}}.facebook.com/plugins.twitter.com/widgets.linkedin.com/widgets
# Allow specific sites{-block}.example.com
# Disable filtering for banking sites{-filter}.bank.com.paypal.comCreating user.filter File
Create a user.filter file for content filtering:
# User-defined filters
# Remove tracking parameters from URLsFILTER: remove-tracking-params Remove tracking query parameterss@\?utm_[^&]*@@gs@&utm_[^&]*@@g
# Remove social sharing buttonsFILTER: remove-social Remove social sharing buttonss@<div[^>]*class="[^"]*share[^"]*"[^>]*>.*?</div>@@gsi
# Clean up cookie noticesFILTER: remove-cookie-notices Remove cookie consent bannerss@<div[^>]*class="[^"]*cookie[^"]*"[^>]*>.*?</div>@@gsiCreating the .dockerignore File
Create a .dockerignore file:
.git.github*.mdLICENSE.gitignore*.log.DS_StoreDeploying Privoxy on Klutch.sh
- Configure port 8118 for HTTP proxy traffic
- Detect your Dockerfile automatically
- Build the container image
- Attach the persistent volumes
- Start the Privoxy container
- Host: your-app-name.klutch.sh
- Port: 8118
Push Your Repository to GitHub
Initialize your repository and push to GitHub:
git initgit add Dockerfile config user.action user.filter .dockerignoregit commit -m "Initial Privoxy deployment configuration"git remote add origin https://github.com/yourusername/privoxy-deploy.gitgit push -u origin mainCreate a New Project on Klutch.sh
Navigate to the Klutch.sh dashboard and create a new project. Give it a descriptive name like “privoxy” or “web-proxy”.
Create a New App
Within your project, create a new app. Connect your GitHub account if you haven’t already, then select the repository containing your Privoxy Dockerfile.
Configure Traffic Settings
Privoxy uses a TCP port. In the deployment settings:
Attach Persistent Volumes
Add the following volumes:
| Mount Path | Recommended Size | Purpose |
|---|---|---|
/etc/privoxy | 100 MB | Configuration files |
/var/log/privoxy | 1 GB | Log files |
Deploy Your Application
Click Deploy to start the build process. Klutch.sh will:
Configure Your Browser
Set your browser’s HTTP proxy to your Privoxy instance:
Configuring Clients
Browser Configuration
Firefox:
- Go to Settings > Network Settings
- Select “Manual proxy configuration”
- Enter your Privoxy host and port
- Check “Use this proxy server for all protocols”
Chrome:
- Go to Settings > System > Open proxy settings
- Configure HTTP proxy in system settings
- Enter your Privoxy host and port
System-Wide Proxy
Linux:
export http_proxy=http://privoxy-host:8118export https_proxy=http://privoxy-host:8118macOS: Set proxy in System Preferences > Network > Advanced > Proxies
Windows: Set proxy in Settings > Network & Internet > Proxy
Creating Custom Rules
Blocking Patterns
Add to user.action:
# Block by domain{+block{Blocked site}}.badsite.com
# Block by URL pattern{+block{Blocked path}}*/ads/**/tracking/*URL Rewriting
Redirect traffic to different URLs:
{+redirect{s@http://old.example.com@https://new.example.com@}}old.example.comContent Modification
Add filters in user.filter:
FILTER: custom-mod Custom content modifications@Original Text@Replacement Text@gTor Integration
To route traffic through Tor, add to your config:
# Forward all traffic through Torforward-socks5t / 127.0.0.1:9050 .
# Exceptions (direct connection)forward .local .forward 192.168.*.* .forward 10.*.*.* .Monitoring and Logging
Accessing Logs
View Privoxy activity logs at /var/log/privoxy/privoxy.log:
2024-01-15 10:30:15.123 Request: example.com/page2024-01-15 10:30:15.456 Crunch: Blocked: google-analytics.comDebug Levels
Configure debug output in config:
debug 1 # Log connectionsdebug 1024 # Log actions applieddebug 4096 # Log content filteringTroubleshooting Common Issues
Connection Refused
Solutions:
- Verify Privoxy is running
- Check listen address includes 0.0.0.0
- Ensure port 8118 is accessible
Pages Not Loading
Solutions:
- Check for overly aggressive blocking rules
- Verify the site isn’t being blocked incorrectly
- Review logs for error messages
HTTPS Issues
Solutions:
- Privoxy doesn’t inspect HTTPS by default
- For HTTPS filtering, configure SSL inspection
- Check certificate configurations
Additional Resources
Conclusion
Deploying Privoxy on Klutch.sh gives you a powerful, centralized web proxy for enhancing privacy across all your devices. With flexible filtering rules and extensive customization options, Privoxy helps you take control of your web browsing experience by blocking ads, removing trackers, and modifying content as you see fit.
Whether used standalone or integrated with Tor, Privoxy provides an essential layer of privacy protection for security-conscious users.