Dataplicity Wormhole allows you to host a website from your Raspberry Pi, regardless of where it is installed, at a specific address (https://<yourdevice>.dataplicity.io/). Port forwarding, firewall exceptions and Dynamic DNS are no longer required. See how it works here.
For Wormhole you will need:
- A Raspberry Pi with a working connection to the internet
- An Operating System installed on your Pi, e.g. Raspbian (see Remote Pi lightweight build)
- Dataplicity installed on your Pi (see Getting started with Dataplicity)
If you're using a version of the Dataplicity Agent installed before April 2016, you'll need to upgrade.
The simplest way to do this is to re-run the Dataplicity install on your Pi, using the one-line installation command available on your Dataplicity account. The command is similar to below (note that yours will have its own unique installation magic code).
curl https://dataplicity.com/<ACCOUNT_MAGIC_CODE>.py | sudo python
Alternatively, you can copy the following directly at your Pi terminal:
sudo pip install --upgrade dataplicity sudo nohup supervisorctl restart tuxtunnel &
If you already have a web service running on your Pi which is listening on localhost port 80, you can skip this section. Otherwise, you'll need to install one. In this example we're going to install a very popular web server called NGINX (pronounced "Engine-X" - any other web server will do).
Type the following into your Pi terminal:
sudo apt-get install nginx
NGINX will usually start by itself, but you should verify that the web server is running:
sudo netstat -an | grep LISTEN | grep :80
The output should indicate that something is listening on port 80:
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN tcp6 0 0 :::80 :::* LISTEN
If you aren't seeing the output above, check your web service is running properly, and perhaps try restarting it:
sudo service nginx restart
To enable Wormhole, log in to your Dataplicity account. You'll want to do this on a laptop. Open up the Device page for your Pi.
You should see a button next to the device name that says "Activate Wormhole":
Click "Activate Wormhole".
If you do not see the "Activate Wormhole" button, check to ensure that you have your Pi connected to the internet and you've correctly updated the Dataplicity client to a recent version. If you have issues, you may re-try the Dataplicity agent installation.
When pressed, the button will be replaced with a direct link to your device, like so:
The green text is a clickable link to the web site on your Pi
Click the link (or type it into your browser). You should see your device website.
The website above is actually running on your Pi. The files for it, and the code for it, are all in the Pi. And if you remove your Pi from your home network and take it to a hackathon, the website link is still the same!
When you switch on Wormhole you are placing the web service hosted on your Pi directly on the wider internet. That's actually the point, but what it means is that you need to take special care in what you put online.
In this case, NGINX is running on port 80 directly from your Pi. Wormhole listens only on localhost, so you don't need to have port 80 open directly from your Pi to the wider world - even though this is not inherently insecure.
Just to avoid confusion it's sensible to close the device port by installing a firewall. Depending on your application you may also wish to enable HTTP basic-authentication from the NGINX configuration, and require a password for website access.
We've put together some basic tips for Securing Wormhole - well worth a read.