I have followed this tutorial on making an 'onion pi'. This is a Wifi Access Point, which routes traffic through tor. This has worked completely and well, although the only problem I have come into is hosting a local server on the raspberry pi running the AP. Trying to use apache2 to host the server, I am not able to access the host on any machines connected to my AP. Firefox gives me "Unable to connect" errors. My raspberry pi has two ip's (one from the AP, one for the router it connects to), but trying both I get nothing, is there some kind of iptable setup I need, or otherwise to allow connections to it.

netstat -tlnp shows:

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0    *               LISTEN      -       
tcp        0      0*               LISTEN      -
tcp        0      0*               LISTEN      - 

*Ommiting unrelated ports.

This shows apache2 is running fine, I think it must be something I must do for the connection.

  • is it normal to have no PID/Program name? In my Rasbian, I have them filled in, what does service apache2 status do ?
    – Havnar
    Commented Sep 3, 2014 at 16:53
  • @Havnar service apache2 status give Apache2 is running (pid 2569). Apache2 is running fine, with a pid, but I don't know why netstat hasn't shown it.
    – ptolemy0
    Commented Sep 3, 2014 at 17:02
  • what port number is apache configured for? ` nano /etc/apache2/sites-enabled/000-default` maybe some program is in the way? have you also tried service apache2 reload service apache2 restart
    – Havnar
    Commented Sep 3, 2014 at 17:18
  • @Havnar restarting apache2 fixes nothing. Although my apache2 vhost is default not 000-default (I assume this doesn't matter), the port is 80.
    – ptolemy0
    Commented Sep 3, 2014 at 17:32
  • Weirdly enough, I am able to ssh to the Pi, so the connection is fine. I think this may be because I did some iptables for port 22 (ssh). As follows sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 22 -j REDIRECT --to-ports 22. What would I change for http (port 80), would it just be the 22's to 80's?
    – ptolemy0
    Commented Sep 3, 2014 at 17:41

1 Answer 1


I have figured this out myself with help from comments.

It needs an iptables command to route traffic through port 80. The following command should do it:

sudo iptables -t nat -A PREROUTING -p tcp -d --dport 80 -j REDIRECT --to-ports 80

Then make the iptables load this on boot with:

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.