← blog

Hosting A Tor Website On Raspberry Pi

Lately, I've been investigating different p2p protocols and I've been long intrigued about the Tor Project. I've been interested in onion routing for quite a while, and have understood it as a software to prevent snooping and to prevent censorship. In a later post I'll explore the onion routing protocol, but I've been intrigued by the idea of .onion websites that can only be accessed by the Tor Network. A TLDR about .onion websites they are a "hidden" service that can be reached by Tor. I recently attended a workshop where I learned how to serve a web page on my computer and make it accessible through the Tor network. So, I decided to create a simple personal web page on a Raspberry Pi and expose it via Tor.

tic tac toe screen grab

To do it, I started with my trusty Raspberry Pi, btw there's a crazy shortage of them! I flashed it with the Ubuntu Server image, lately I've been using Ubuntu servers and have found them quite comfortable to use.

I pretty much followed the instructions from Tor to get Tor up and running on my Raspberry Pi. The steps are pretty straightforward, however, the Raspberry Pi uses the Arm64 chip and my distribution is apparently jammy. This can be discovered by running the lsb_release -a command.

I created a simple webpage on my Pi. I created a file named torrc with the default torrc contents. I only modify the HiddenServiceDir line to direct to my web directory. Next, I served the webpage using Python simple http server with python -m http.serve --directory public 3000. I can then start the tor software to expose the web page through the tor network using tor -f torrc. This creates a hidden_service directory. If you cat the hostname file then you can get your onion link!

You can see my .onion website using Brave Browser or Tor Browser at http://2ts2663mdreoynk6jncg4jrcufohzqalt4oijv7px6gbykaeskvwcfad.onion/.