Konstantinos Antoniou.

← Projects

WordPress Portfolio Deployment with Docker and Cloudflare Tunnel

Introduction

To host this personal portfolio website, I deployed a WordPress instance inside a Docker container, ensuring portability, easy maintenance, and version control. The website serves as a hub for my technical projects, automation work, and documentation.
To enhance security and availability, I integrated a Cloudflare Tunnel to provide end-to-end SSL/TLS encryption without exposing my server directly to the internet.

This setup eliminates the need for traditional port forwarding and leverages Cloudflare’s global network for secure HTTPS access, even behind NAT or dynamic IPs.


Infrastructure Overview

  • Platform: Debian Server (VM host on Proxmox)
  • Containerization: Docker + Docker Compose
  • Service Stack:
    • WordPress (frontend CMS)
    • Mysql (database backend)
    • Cloudflare Tunnel (for encrypted web access)
  • Reverse Proxy: Cloudflare Tunnel handles secure HTTPS termination
  • Storage: WordPress and Mysql data stored in persistent Docker volumes

docker-compose.yaml

Below is the configuration i used to deploy the project:

services:

  wordpress:
    image: wordpress:latest
    container_name: wordpress_app
    restart: always
    ports:
      - 8081:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: username
      WORDPRESS_DB_PASSWORD: super-secure-password
      WORDPRESS_DB_NAME: portfoliodb
    volumes:
      - /opt/appdata/wordpress/app:/var/www/html

  db:
    image: mysql:8.0
    container_name: wordpress_db
    restart: always
    environment:
      MYSQL_DATABASE: portfoliodb
      MYSQL_USER: username
      MYSQL_PASSWORD: super-secure-password
      MYSQL_RANDOM_ROOT_PASSWORD: '1'
    volumes:
      - /opt/appdata/wordpress/db:/var/lib/mysql

  cloudflared:
    image: cloudflare/cloudflared:latest
    container_name: wordpress_domain
    restart: always
    command: tunnel --no-autoupdate run --token <token>

I do not describe how i designed my portfolio website as it is out of the deployment scope!


Cloudflare Tunnel Configuration and Usage

A Cloudflare Tunnel securely connects your local or private web services to the internet without the need for opening ports, configuring firewalls, or dealing with dynamic IPs.
Instead of exposing my server directly, Cloudflare Tunnel establishes an outbound encrypted connection between my host and Cloudflare’s global network.
This means my WordPress container remains completely hidden from the public internet while still being accessible over HTTPS through my domain.


1. Prerequisites

  • A Cloudflare account
  • A domain already added to Cloudflare (mine, black-crab.cc)
  • Docker installed on my server
  • The cloudflared Docker image (Cloudflare’s tunnel client)

2. Create a Tunnel from the Cloudflare Dashboard

Screenshot 1: 2. Create a Tunnel from the Cloudflare Dashboard

  • Navigate to Zero Trust → Networks → Tunnels.

Screenshot 2: 2. Create a Tunnel from the Cloudflare Dashboard

  • Click Create a Tunnel, name it something like portfolio.

Screenshot 3: 2. Create a Tunnel from the Cloudflare Dashboard

  • Choose Docker or Debian/Linux as the platform.

  • Copy the tunnel token provided by Cloudflare — it looks something like:

Screenshot 4: 2. Create a Tunnel from the Cloudflare Dashboard

eyJhIjoiZ……0iLCJzIjo…

  • Do not expose any ports; the tunnel client will connect outward.

3. Run the Tunnel with Docker

I deployed the tunnel as part of my Docker Compose stack, i could also deploy it standalone.

cloudflared:
  image: cloudflare/cloudflared:latest
  container_name: cloudflared_tunnel
  restart: unless-stopped
  command: tunnel run wordpress-portfolio
  environment:
    - TUNNEL_TOKEN=
  depends_on:
    - wordpress

This container connects automatically to Cloudflare using the tunnel token and links my WordPress container to the public domain.


4. Configure Public Access (DNS Mapping)

Once the tunnel is active:

  1. Return to Cloudflare dashboard.
  2. Go to Zero Trust → Networks → Tunnels → portfolio → Add a published application route**.**

Screenshot 5: 4. Configure Public Access (DNS Mapping)

Screenshot 6: 4. Configure Public Access (DNS Mapping)

Under Published application routes, complete the Domain details:

Screenshot 7: 4. Configure Public Access (DNS Mapping)

Save and deploy.

Cloudflare automatically creates a DNS record (portfolio.black-crab.cc) pointing to my tunnel — no IPs or NAT rules required.


5. Verify the Tunnel

Once the tunnel connects successfully, i see a message in the container logs:

Connection established. You can now visit your site through Cloudflare!

I also can confirm the connection with:

docker logs cloudflared_tunnel

Then open in a browser:

https://portfolio.black-crab.cc


6. Benefits of Cloudflare Tunnel

  • No port forwarding: Only outbound traffic from my host
  • Full SSL/TLS encryption: End-to-end protection managed automatically
  • High availability: Served via Cloudflare’s global edge network
  • Integrated access control: I can add authentication, rate limiting, and WAF rules directly from Cloudflare

Summary

By combining Docker and Cloudflare Tunnel, my WordPress portfolio gains strong security, simplified deployment, and effortless HTTPS management — all without needing a public IP or manual certificate setup.
My infrastructure remains compact and portable, and the tunnel makes my site both secure and globally reachable.


Outcome

The result is a self-contained WordPress environment that can be easily backed up or migrated by copying the Docker volumes.
With Cloudflare Tunnel, my site benefits from:

  • End-to-end SSL encryption without manual certificate management
  • Zero exposed ports on the public internet
  • Improved resilience through Cloudflare’s distributed edge network

This setup demonstrates a modern, containerized web deployment workflow suitable for both personal and professional projects.