Proxies

Revision as of 05:34, 7 September 2024 by Maintenance script (talk | contribs) (Initial)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Proxies: Serving, Using, and TOR

Context

Outcome

This guide will help you configure your system to route all network traffic through the Tor network using Privoxy. By the end of this guide, your internet traffic will be anonymized, enhancing your privacy and security.

Benefits

Routing all traffic through Tor provides several benefits: - Anonymity: Tor hides your IP address by routing your traffic through multiple nodes. - Privacy: Your internet service provider (ISP) and other third parties cannot easily monitor your online activities. - Access to Restricted Content: You can access content that may be blocked or restricted in your region.

Tor vs. VPN

Tor: Tor is a free, decentralized network that anonymizes your traffic by routing it through multiple volunteer-operated nodes. It is particularly effective for high privacy needs but may be slower due to multiple hops. VPN: A VPN provides encryption and routes your traffic through a server operated by the VPN provider. VPNs can offer faster speeds and are easier to use but require trust in the VPN provider.

Proxy vs. VPN

Proxy: A proxy routes your internet traffic through a single server, hiding your IP address but not necessarily encrypting your data. Proxies are useful for accessing geo-restricted content but offer less security than VPNs or Tor. VPN: A VPN encrypts all your traffic and routes it through a secure server, providing both privacy and security. VPNs are generally faster than Tor but require trust in the VPN provider.

Privacy and Security Considerations

Serving a Proxy

When setting up a proxy server, consider the following: - Security: Ensure the server is secured to prevent unauthorized access. Use strong passwords and consider setting up a firewall. - Privacy: Be aware that the server can log all traffic passing through it. If privacy is critical, configure the server to avoid logging or encrypt logs.

Using a Proxy

When using a proxy server, consider the following: - Anonymity: Your traffic is routed through the proxy, masking your IP address but not necessarily encrypting your data. - Trust: Ensure you trust the proxy server you are using, as it can potentially log your traffic and access sensitive information.

Routing All Traffic Through Tor Using Privoxy

For macOS

Step 1: Install Tor and Privoxy

First, we need to install both Tor and Privoxy using Homebrew.

  1. Install Homebrew (if not already installed):

    <syntaxhighlight lang="sh">/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"</syntaxhighlight>
  2. Install Tor:

    <syntaxhighlight lang="sh">brew install tor</syntaxhighlight>
  3. Install Privoxy:

    <syntaxhighlight lang="sh">brew install privoxy</syntaxhighlight>

Step 2: Configure Privoxy to Use Tor

Edit the Privoxy configuration file to route traffic through Tor.

  1. Open Privoxy’s Configuration File:

    <syntaxhighlight lang="sh">nano /opt/homebrew/etc/privoxy/config</syntaxhighlight>
  2. Add Tor Configuration: Add the following line to the configuration file:

    forward-socks5t / 127.0.0.1:9050 .
  3. Save and Exit:

    • Press CTRL + X to exit.
    • Press Y to confirm saving the changes.
    • Press Enter to save the file.

Step 3: Start Privoxy

Start Privoxy as a background service.

  1. Start Privoxy:

    <syntaxhighlight lang="sh">brew services start privoxy</syntaxhighlight>

Step 4: Configure macOS to Use Privoxy as a System Proxy

Configure your macOS network settings to use Privoxy.

Open System Preferences:

  1. Go to System Preferences > Network.

Select the Network Interface:

  1. Select the network interface you are using (e.g., Wi-Fi or Ethernet).

Configure Proxies:

  1. Click on Advanced.
  2. Go to the Proxies tab.
  3. Check Web Proxy (HTTP) and Secure Web Proxy (HTTPS).
  4. Set both to 127.0.0.1 and 8118 (Privoxy’s default port).

Apply Changes:

  1. Click OK and Apply.

Step 5: Verify the Configuration

Ensure that your traffic is being routed through Tor.

  1. Check IP Address: Open a web browser and navigate to http://check.torproject.org. This page should confirm that your traffic is being routed through the Tor network.

  2. Test Connection: Use curl to verify the connection:

    <syntaxhighlight lang="sh">curl -L --proxy http://127.0.0.1:8118 http://check.torproject.org</syntaxhighlight>

Example Privoxy Configuration

Here is an example of what your Privoxy configuration might look like after editing:

# Forward all traffic through Tor
forward-socks5t / 127.0.0.1:9050 .

For Linux

Step 1: Install Tor and Privoxy

First, we need to install both Tor and Privoxy.

  1. Update Package List:

    <syntaxhighlight lang="sh">sudo apt update</syntaxhighlight>
  2. Install Tor:

    <syntaxhighlight lang="sh">sudo apt install tor</syntaxhighlight>
  3. Install Privoxy:

    <syntaxhighlight lang="sh">sudo apt install privoxy</syntaxhighlight>

Step 2: Configure Privoxy to Use Tor

Edit the Privoxy configuration file to route traffic through Tor.

  1. Open Privoxy’s Configuration File:

    <syntaxhighlight lang="sh">sudo nano /etc/privoxy/config</syntaxhighlight>
  2. Add Tor Configuration: Add the following line to the configuration file:

    forward-socks5t / 127.0.0.1:9050 .
  3. Save and Exit:

    • Press CTRL + X to exit.
    • Press Y to confirm saving the changes.
    • Press Enter to save the file.

Step 3: Start Privoxy

Start Privoxy as a background service.

  1. Start Privoxy:

    <syntaxhighlight lang="sh">sudo systemctl start privoxy

    sudo systemctl enable privoxy</syntaxhighlight>

Step 4: Configure Linux to Use Privoxy as a System Proxy

Configure your Linux network settings to use Privoxy.

Open Network Settings:

  1. Go to Settings > Network.

Select the Network Interface:

  1. Select the network interface you are using (e.g., Wired or Wi-Fi).

Configure Proxies:

  1. Click on Settings (gear icon) for the network interface.
  2. Go to the Proxy tab.
  3. Set the proxy method to Manual.
  4. Enter 127.0.0.1 and 8118 for HTTP and HTTPS proxies.

Apply Changes:

  1. Click Apply.

Step 5: Verify the Configuration

Ensure that your traffic is being routed through Tor.

  1. Check IP Address: Open a web browser and navigate to http://check.torproject.org. This page should confirm that your traffic is being routed through the Tor network.

  2. Test Connection: Use curl to verify the connection:

    <syntaxhighlight lang="sh">curl -L --proxy http://127.0.0.1:8118 http://check.torproject.org</syntaxhighlight>

Example Privoxy Configuration

Here is an example of what your Privoxy configuration might look like after editing:

# Forward all traffic through Tor
forward-socks5t / 127.0.0.1:9050 .

Serving a Proxy from macOS or Linux System

For macOS

Step 1: Install Privoxy

  1. Install Homebrew (if not already installed):

    <syntaxhighlight lang="sh">/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"</syntaxhighlight>
  2. Install Privoxy:

    <syntaxhighlight lang="sh">brew install privoxy</syntaxhighlight>

Step 2: Configure Privoxy to Allow Remote Connections

  1. Open Privoxy’s Configuration File:

    <syntaxhighlight lang="sh">nano /opt/homebrew/etc/privoxy/config</syntaxhighlight>
  2. Add Remote Access Configuration: Add the following lines to the configuration file to allow remote connections:

    listen-address  0.0.0.0:8118
  3. Save and Exit:

    • Press CTRL + X to exit.
    • Press Y to confirm saving the changes.
    • Press Enter to save the file.

Step 3: Start Privoxy

  1. Start Privoxy:

    <syntaxhighlight lang="sh">brew services start privoxy</syntaxhighlight>

Step 4: Set Up Port Forwarding

  1. Configure Your Router: Ensure your router forwards external traffic on port 8118 to your macOS machine’s IP address. You can find your IP address using:

    <syntaxhighlight lang="sh">PUBLIC_IP=$(curl -s ifconfig.me)

    echo $PUBLIC_IP</syntaxhighlight>

Step 5: Secure Remote Access with SSH Tunneling

  1. Create SSH Tunnel Script: Create a script to automate the creation of an SSH tunnel. Replace your_macOS_username with your actual macOS username.

    <syntaxhighlight lang="sh">PUBLIC_IP=$(curl -s ifconfig.me) echo "ssh -L 8118:localhost:8118 $(whoami)@$PUBLIC_IP" > connect_proxy.sh

    chmod +x connect_proxy.sh</syntaxhighlight>
  2. Run the Script on the Remote Machine: On your remote machine, run the script to create an SSH tunnel:

    <syntaxhighlight lang="sh">./connect_proxy.sh</syntaxhighlight>
  3. Configure Remote Device to Use Proxy: On your remote device, configure your web browser or system settings to use the proxy:

    • HTTP Proxy: 127.0.0.1
    • Port: 8118

For Linux

Step 1: Install Privoxy

  1. Update Package List:

    <syntaxhighlight lang="sh">sudo apt update</syntaxhighlight>
  2. Install Privoxy:

    <syntaxhighlight lang="sh">sudo apt install privoxy</syntaxhighlight>

Step 2: Configure Privoxy to Allow Remote Connections

  1. Open Privoxy’s Configuration File:

    <syntaxhighlight lang="sh">sudo nano /etc/privoxy/config</syntaxhighlight>
  2. Add Remote Access Configuration: Add the following lines to the configuration file to allow remote connections:

    listen-address  0.0.0.0:8118
  3. Save and Exit:

    • Press CTRL + X to exit.
    • Press Y to confirm saving the changes.
    • Press Enter to save the file.

Step 3: Start Privoxy

  1. Start Privoxy:

    <syntaxhighlight lang="sh">sudo systemctl start privoxy

    sudo systemctl enable privoxy</syntaxhighlight>

Step 4: Set Up Port Forwarding

  1. Configure Your Router: Ensure your router forwards external traffic on port 8118 to your Linux machine’s IP address. You can find your IP address using:

    <syntaxhighlight lang="sh">PUBLIC_IP=$(curl -s ifconfig.me)

    echo $PUBLIC_IP</syntaxhighlight>

Step 5: Secure Remote Access with SSH Tunneling

  1. Create SSH Tunnel Script: Create a script to automate the creation of an SSH tunnel. Replace your_linux_username with your actual Linux username.

    <syntaxhighlight lang="sh">PUBLIC_IP=$(curl -s ifconfig.me) echo "ssh -L 8118:localhost:8118 $(whoami)@$PUBLIC_IP" > connect_proxy.sh

    chmod +x connect_proxy.sh</syntaxhighlight>
  2. Run the Script on the Remote Machine: On your remote machine, run the script to create an SSH tunnel:

    <syntaxhighlight lang="sh">./connect_proxy.sh</syntaxhighlight>
  3. Configure Remote Device to Use Proxy: On your remote device, configure your web browser or system settings to use the proxy:

    • HTTP Proxy: 127.0.0.1
    • Port: 8118

Connecting to the Proxy from a Remote System

For macOS

Step 1: Create SSH Tunnel

  1. Run the SSH Tunnel Script: On your macOS remote machine, run the script created previously to establish an SSH tunnel:

    <syntaxhighlight lang="sh">./connect_proxy.sh</syntaxhighlight>

Step 2: Configure macOS to Use the Proxy

Open System Preferences:

  1. Go to System Preferences > Network.

Select the Network Interface:

  1. Select the network interface you are using (e.g., Wi-Fi or Ethernet).

Configure Proxies:

  1. Click on Advanced.
  2. Go to the Proxies tab.
  3. Check Web Proxy (HTTP) and Secure Web Proxy (HTTPS).
  4. Set both to 127.0.0.1 and 8118.

Apply Changes:

  1. Click OK and Apply.

For Windows

Step 1: Create SSH Tunnel

Install PuTTY (if not already installed):

  1. Download and install PuTTY from here.

Configure SSH Tunnel:

  1. Open PuTTY.
  2. Enter the hostname or IP address of your proxy server.
  3. In the left-hand menu, go to Connection > SSH > Tunnels.
  4. Add a new forwarded port:
  5. Source port: 8118
  6. Destination: localhost:8118
  7. Click Add.
  8. Go back to the Session category.
  9. Click Open to start the SSH session.

Step 2: Configure Windows to Use the Proxy

Open Internet Options:

  1. Go to Control Panel > Internet Options.

Configure LAN Settings:

  1. Go to the Connections tab and click on LAN settings.
  2. Check Use a proxy server for your LAN.
  3. Enter 127.0.0.1 for the address and 8118 for the port.
  4. Click OK to apply the changes.

For iOS

Step 1: Create SSH Tunnel

Install an SSH Client:

  1. Install an SSH client like Termius from the App Store.

Configure SSH Tunnel:

  1. Open Termius.
  2. Add a new host with the IP address of your proxy server.
  3. Go to the Port Forwarding section and add a new rule:
  4. Local port: 8118
  5. Remote host: localhost
    • Remote port: 8118
  6. Connect to the host to start the tunnel.

Step 2: Configure iOS to Use the Proxy

Configure Wi-Fi Proxy:

  1. Go to Settings > Wi-Fi.
  2. Tap the information icon (i) next to your Wi-Fi network.
  3. Scroll down to HTTP Proxy and select Manual.
  4. Enter 127.0.0.1 for the Server and 8118 for the Port.
  5. Save the settings.

For Android

Step 1: Create SSH Tunnel

Install an SSH Client:

  1. Install an SSH client like ConnectBot from the Google Play Store.

Configure SSH Tunnel:

  1. Open ConnectBot.
  2. Add a new host with the IP address of your proxy server.
  3. Go to the port forwarding section and add a new rule:
  4. Type: Local
  5. Source port: 8118
  6. ' Destination: localhost:8118
  7. Connect to the host to start the tunnel.

Step 2: Configure Android to Use the Proxy

Configure Wi-Fi Proxy:

  1. Go to Settings > Network & Internet > Wi-Fi.
  2. Long-press your connected Wi-Fi network and select Modify network.
  3. Scroll down and select Advanced options.
  4. Set Proxy to Manual.
  5. Enter 127.0.0.1 for the Hostname and 8118 for the Port.
  6. Save the settings.