Host a website on a Raspberry Pi without port forwarding

· Guides

A Raspberry Pi makes a great little web server: quiet, cheap to run, and always on. Getting it reachable from the internet is usually the annoying part. Here is how to put a site on a Pi online at a permanent address with no router settings at all.

What you need

1. Install the command-line node

Link Node's command-line edition is open source (MIT) and is a single file with nothing else to install. Pick the build for your Pi: linux-arm64 for 64-bit Raspberry Pi OS, linux-armv7 for 32-bit.

curl -LO https://github.com/betterbotbureau/linkus/releases/latest/download/linknode-linux-arm64
sudo install linknode-linux-arm64 /usr/local/bin/linknode
linknode run

The first run creates the node's identity (a key that never leaves the Pi) and the folder ~/Link/public, and prints the site's address. Press Ctrl-C once you have seen it.

2. Add your site

Copy your pages into ~/Link/public. index.html is the homepage; HTML, CSS, images and JavaScript are served as they are. No site yet? While the folder is still empty, linknode example writes a complete example site to start from. On the Pi itself, the local preview is at http://localhost:7465/.

3. Keep it running

Install the systemd unit so the node starts with the Pi and restarts if anything goes wrong:

sudo curl -Lo /etc/systemd/system/linknode@.service \
  https://raw.githubusercontent.com/betterbotbureau/linkus/main/deploy/linknode@.service
sudo systemctl enable --now linknode@$USER

4. Publish

linknode publish on
linknode status

linknode status shows Published: yes and the public address, like https://58310427.mdoc.us/. That address is permanent: it stays the same when your home IP changes or the Pi restarts.

How it gets through your router

Visitors' browsers connect to the Pi directly over an encrypted WebRTC link. Link Node asks your router for a port mapping where the router allows it, and otherwise uses the usual techniques for getting through home routers, the same ones video calls use. The Link service only introduces the two sides; it never carries your pages. That also means it does not depend on port forwarding, so it works on many connections where port forwarding is impossible.

A few strict networks block direct connections entirely. Visitors on those see a clear message instead of your site, because Link never relays traffic through its own servers.

Handy commands

The source, every release and the install guide are on GitHub.

Try it: Link Node is free, with no account. Download it for Windows, Mac or Linux, or run the open-source command-line node on a Raspberry Pi.

Download Link Node