How to set up Tor proxy with Raspberry Pi

Are you worried about online privacy? Perhaps you are interested in protecting your personal information from online marketers and advertisers who may want to use the data without your permission, or sell your information you to a third party. Regardless of the engine, the Tor network is one of the most common ways to avoid any form of online surveillance.

In today's article, you'll learn how to set up a Tor proxy on your Raspberry Pi and use it to automatically route traffic through Tor whenever you connect to your home network.

Set up Tor proxy with Raspberry Pi for secure browsing

  • What is the Tor proxy server?
  • Things to prepare
  • Get started: Set up a Raspberry Pi
  • Install Tor on the Raspberry Pi
  • Configure the Tor proxy server
  • Connect to Tor proxy from any web browser
  • Mozilla Firefox
  • Google Chrome (and other Chromium-based browsers)
  • Apple Safari
  • What is the Tor proxy server?

    Proxy servers act as intermediaries for clients who are requesting resources from the server, such as files or web pages.

    When you set up the Tor proxy server, all traffic will be redirected through the Tor network. Each data packet you send via Tor is encrypted and decoded multiple times, then redirected through a number of relays, randomly selected from the thousands of relays that make up the Tor network. This way, you can hide your location and activity from anyone who is watching the network, including hiding the websites you visit, messages you send and any posts you make.

    Many people access Tor through the free Tor browser, but this requires setting up the browser on any device you have Internet access. If you want to use the Tor network on all your devices or surf the web anonymously with your current web browser, it's often easier to set up the Tor proxy server, which is what you'll learn in the next section this lead.

    Things to prepare

    To complete this tutorial, you will need:

  • Raspberry Pi runs Raspberry Pi OS
  • The power cable is compatible with the Raspberry Pi
  • External keyboard and how to attach it to a Raspberry Pi
  • HDMI or micro HDMI cables, depending on the Raspberry Pi model
  • External screen
  • Ethernet cable (if not connected via WiFi)
  • Get started: Set up a Raspberry Pi

    To get started, connect all peripherals to the Raspberry Pi.

    When the Raspberry Pi starts, click the small network icon on the toolbar and connect to a WiFi network, if you don't use an Ethernet cable.

    Before you begin, you should check that you are running the latest version of the Raspberry Pi OS. Open Terminal and type the following command:

    sudo apt update && sudo apt -y upgrade

    If you have installed one or more updates, restart your Raspberry Pi by running the following command:

    sudo reboot

    Install Tor on the Raspberry Pi

    You can install Tor with a single Terminal command:

    sudo apt install tor

    You can install the Tor software on a Raspberry Pi with a single command.

    You now have 2 new services running on your Raspberry Pi: tor.service and tor@default.service.

    Service tor is only symbolic. To check if the actual tor @ default service is running, use the following Terminal command:

    sudo systemctl status tor@default.service
    Picture 1 of How to set up Tor proxy with Raspberry Pi Check if the actual tor @ default service is running

    If the Terminal returns an active message , you're ready to move on to the next step.

    Configure the Tor proxy server

    Set up the proxy server by making some changes to the Tor configuration file. Before editing this 'torr' file , you should make a backup:

    sudo cp /etc/tor/torrc /etc/tor/torrc.backup

    Now that you have the backup, create a simple configuration, specify the Tor Socks proxy service on port 9050 and accept connections from the local LAN.

    To open the 'torr' configuration file and edit, run the following command:

    sudo nano /etc/tor/torrc

    This file will now launch in the Nano editor. First, identify SocksPort , which is the IP address of your Raspberry Pi. You can get this information by running the following Terminal command:

    hostname -I

    Get this IP address and add the port number : 9050. For example, if the Raspberry Pi's IP address is 192.168.1.111, then add the following to the Torr configuration file:

    SocksPort 192.168.1.111:9050

    Add the following to the Nano editor, making sure to replace SocksPort with your own value:

    SocksPort 192.168.1.100:9050 SocksPolicy accept 192.168.1.0/24 RunAsDaemon 1 DataDirectory /var/lib/tor

    Once you have made the changes, save the file by pressing Ctrl+ Oand Ctrl+ Xto close.

    To restart the Tor service with the new configuration, run the following command:

    sudo systemctl restart tor@default.service

    Connect to Tor proxy from any web browser

    In this final section, you will learn how to connect to a Raspberry Pi server, using all major web browsers.

    Note that you will usually connect to a Raspberry Pi using an IP address. You can access this information at any time by running it hostname -Iin the Raspberry Pi Terminal.

    Mozilla Firefox

    Start by configuring Firefox to use the proxy server:

    1. In the upper right corner of Firefox, select the three horizontal lines icon.

    2. Select Preferences.

    3. In the menu on the left, select General.

    4. Scroll to Network Settings and click the Settings button .

    5. In the Connection Settings window , select the Manual proxy configuration checkbox .

    Picture 2 of How to set up Tor proxy with Raspberry Pi Select the Manual proxy configuration checkbox

    6. In the SOCKS Host field , enter the IP address of the Raspberry Pi.

    7. In the Port section , enter 9050.

    8. Make sure the SOCKS v5 checkbox is selected.

    9. Click OK.

    10. Close and relaunch Firefox!

    Google Chrome (and other Chromium-based browsers)

    Are you using Chrome? To point Google Chrome towards the proxy server:

    1. In the upper right corner of Chrome, select the three dot icon.

    2. Select Settings.

    3. In the menu on the left, navigate to Advanced> System .

    Picture 3 of How to set up Tor proxy with Raspberry Pi Navigate to Advanced> System

    4. Select Open your computer's proxy settings .

    The next steps will vary, depending on the operating system.

    macOS

    If you're a Mac user, Google Chrome will launch the Mac's Network> Proxies menu . In this window:

  • Select SOCKS Proxy.
  • Picture 4 of How to set up Tor proxy with Raspberry Pi Select SOCKS Proxy
  • In SOCKS Proxy Server , enter the IP address of the Raspberry Pi.
  • In the enclosed text box, enter the port number of 9050.
  • Save the changes by clicking OK> Apply .
  • Close and then relaunch Chrome.
  • Windows

    If you are using a Windows PC, Google Chrome will launch an Internet Options window . In this window:

  • Select the LAN settings button .
  • Select the following checkbox: Use a proxy server for your LAN .
  • Click on Advanced.
  • In the Socks section , enter the IP address of the Raspberry Pi.
  • In the Port section , enter 9050.
  • Click Save> Apply .
  • Relaunch Google Chrome.
  • Apple Safari

    If you use the Apple Safari browser, then:

    1. In the Safari toolbar, select Safari> Preferences .

    2. Select the Advanced tab .

    3. Find Proxies and select the Change Settings button .

    4. In the left menu, select SOCKS Proxy .

    5. In SOCKS Proxy Server , enter the IP address of the Raspberry Pi.

    6. In the accompanying text field, enter the port number of 9050.

    7. Save the changes by clicking OK> Apply .

    8. Don't forget to relaunch Safari!

    ncG1vNJzZmismaXArq3KnmWcp51ktbDDjK2mZquVqXq2vIytpqtloKe8ucWMsKCtoF2nrrS8wZ6pq7FdpbY%3D