
Self-Hosting AyoubLab: Hetzner Cloud, Nginx Reverse Proxy & Zero-Trust Tailscale Mesh
Self-Hosting AyoubLab: Hetzner Cloud, Nginx Reverse Proxy & Zero-Trust Tailscale Mesh
A personal engineering lab is more than just a place to host a portfolio—it is an active sandbox to experiment with production architectures, test containerized deployments, and master modern infrastructure.
When setting up AyoubLab (ayoublab.com), my goal was to build a secure, high-performance personal cloud environment adhering to modern DevSecOps standards.
Here is a breakdown of the architecture, networking, and security design.
Architecture Overview
[ Public Web Traffic ]
│
▼ (Ports 80/443 only)
┌───────────────────────────────────────────────┐
│ Hetzner Cloud VPS │
│ │
│ ┌───────────────────────────────────────┐ │
│ │ Nginx Reverse Proxy │ │
│ │ SSL Termination / Let's Encrypt │ │
│ │ Rate Limiting & Security Headers │ │
│ └──────────────────┬────────────────────┘ │
│ │ │
│ ┌───────────┴───────────┐ │
│ ▼ ▼ │
│ [ Next.js App ] [ Docker Staging ] │
│ │
│ ┌───────────────────────────────────────┐ │
│ │ Tailscale Mesh Network │ │
│ │ (No open SSH/DB ports to the world) │ │
│ └──────────────────▲────────────────────┘ │
└──────────────────────┼────────────────────────┘
│ WireGuard Encrypted Tunnel
[ Administrator Device ]
1. Cloud Infrastructure & Web Server Management
We provisioned a dedicated cloud virtual private server on Hetzner infrastructure due to its outstanding price-to-performance ratio and European data privacy standards.
Nginx as a Secure Reverse Proxy
Nginx serves as the public entry point:
- SSL Termination: Automated certificate provisioning and renewals via Let's Encrypt / Certbot.
- HTTP/2 & Modern Ciphers: Enforcing TLS 1.3, strict HSTS, and robust security headers (Content Security Policy, X-Frame-Options).
- Traffic Routing & Load Balancing: Reverse proxying incoming traffic to local Node.js / Next.js instances and containerized Docker services.
server {
server_name ayoublab.com www.ayoublab.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
2. Zero-Trust Networking with Tailscale
The biggest vulnerability of self-hosted servers is leaving administrative ports (like SSH port 22, database port 5432, or Docker management consoles) open to the public internet.
Instead of traditional port-forwarding or complex VPN configurations, we implemented Zero-Trust mesh networking via Tailscale:
- Portless Administration: All public firewall rules on the server reject incoming connections on SSH and database ports.
- Encrypted Mesh: The server and developer machines join a private Tailscale tailnet over peer-to-peer WireGuard tunnels.
- Secure Access: Remote terminal access and database management tools (Prisma Studio, pgAdmin) connect directly through internal mesh IP addresses (e.g.,
100.x.y.z), completely invisible to public scanners and botnets.
3. Custom Mail Server & DNS Architecture
Managing your own domain requires strict DNS hygiene to ensure high deliverability and prevent spoofing:
- DNS Records: Configured root and wildcard records with fast TTLs for flexible staging deployments.
- Hetzner Webmail & Custom Email: Implemented secure custom-domain email infrastructure (
ayoub@ayoublab.com). - SPF, DKIM, and DMARC: Configured standard cryptographic mail records ensuring outbound emails pass strict anti-spam filters.
4. The "Engineering Lab" Concept
AyoubLab is designed as a continuous learning environment where I test:
- Next.js and Prisma full-stack architectures.
- Dockerized microservice templates before promoting them to enterprise projects.
- Experimental IoT integrations and real-time WebSocket pipelines.
Self-hosting your own cloud infrastructure provides hands-on mastery over networking, Linux systems administration, and security that cannot be replicated in isolated local environments.

About the Author
Ayoub Bourhfella is a Full-Stack Web & Mobile Developer on the Digitalization Team at CITIC Dicastal, 1st Place Champion at EnergySkills RSK 2025, and 2nd Place Winner at the AFZIA Digital Competition. Specializes in .NET, React TypeScript monorepos, and cloud infrastructure.