pexels pixabay 163073

Host Your Own Website on a Raspberry Pi with Docker and Cloudflare Tunnels

Host a real website from your living room

Managed hosting is convenient, but there’s something satisfying about running a website on hardware you own. And with Cloudflare Tunnels, the awkward bits – dynamic IP addresses, port forwarding, SSL certificates – are handled for you. Your Pi becomes a legitimate web server accessible via a proper domain name, with HTTPS, no router configuration required.

This works particularly well for personal blogs, portfolios, or small sites that don’t need enterprise-grade uptime. If you’ve already got a Raspberry Pi running Docker from earlier posts in this series, you’re most of the way there.

What you’ll need

  • A Raspberry Pi 3B or newer with Docker installed
  • A domain name (any registrar – Cloudflare, Namecheap, etc.)
  • A free Cloudflare account with your domain added

Choosing your platform

Both WordPress and Ghost run well on a Pi 4 for personal/low-traffic use:

  • WordPress – familiar to most people, vast plugin ecosystem, straightforward Docker setup
  • Ghost – faster, cleaner, better suited to pure blogging, also available as a Docker image

Ghost is the better technical choice for a blog; WordPress wins if you need plugins or a non-technical editor.

Deploying Ghost with Docker Compose

version: '3'

services:
  ghost:
    image: ghost:latest
    restart: unless-stopped
    ports:
      - 2368:2368
    volumes:
      - ghost-data:/var/lib/ghost/content
    environment:
      - url=https://yourdomain.com
      - NODE_ENV=production

volumes:
  ghost-data:

Start it:

docker compose up -d

Ghost will be running on port 2368. Now you need to expose it to the internet.

Setting up a Cloudflare Tunnel

Cloudflare Tunnel creates a secure outbound connection from your Pi to Cloudflare’s network. Incoming requests for your domain travel through Cloudflare and reach your Pi via this tunnel, so you never need to open ports on your router.

Install cloudflared:

curl -L --output cloudflared.deb https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm64.deb
sudo dpkg -i cloudflared.deb

Log in to Cloudflare:

cloudflared tunnel login

Create a tunnel:

cloudflared tunnel create my-blog

Create a config file at ~/.cloudflared/config.yml:

tunnel: <your-tunnel-id>
credentials-file: /home/pi/.cloudflared/<your-tunnel-id>.json

ingress:
  - hostname: yourdomain.com
    service: http://localhost:2368
  - service: http_status:404

Route your domain and start the tunnel:

cloudflared tunnel route dns my-blog yourdomain.com
cloudflared tunnel run my-blog

Install it as a service so it starts automatically:

sudo cloudflared service install

What you get

Browse to your domain and you’ll see your Ghost blog over HTTPS, with a Cloudflare-issued certificate, served from your Pi. Cloudflare also handles DDoS protection and caching automatically – a genuinely useful set of protections for something running on home hardware.

Performance and limits

A Pi 4 handles personal blog traffic without breaking a sweat. Ghost is efficient and the Cloudflare layer caches content aggressively. Where this falls down is sustained high traffic – it’s not the right setup for anything expecting thousands of concurrent visitors. For a personal site, a portfolio, or a technical blog, it’s more than adequate.

This is part eight of our “Things to do with your old Raspberry Pi” series. Next week: RetroPie and the art of building a proper retro gaming console.


Leave a Reply