A production-ready, single-server Docker Compose setup for hosting multiple websites and services on a dedicated server (tested on Intel i5-13500, 64GB RAM, 2x512GB NVMe).
- Traefik v3 - Reverse proxy with automatic Let's Encrypt SSL
- Authelia - SSO/2FA authentication gateway
- Next.js app - Server-side rendered website
- Nginx static site - Static HTML/SPA hosting
- WordPress x2 - PHP 8.3 + MariaDB with Redis object cache
- Umami - Privacy-focused web analytics
- MariaDB 11 - MySQL-compatible (WordPress, Uptime Kuma)
- PostgreSQL 17 - (Umami, n8n)
- Redis 7 - Object cache for WordPress
- Grafana 11 - Dashboards & visualization
- Prometheus v3 - Metrics storage (30-day retention)
- Loki 3 - Log aggregation (30-day retention)
- Grafana Alloy - Unified collector (host metrics, container metrics, Docker logs, DB metrics)
- Uptime Kuma - Uptime monitoring & status pages
- n8n - Workflow automation
- ntfy - Push notifications
- Watchtower - Automatic Docker image updates
- Homepage - Service dashboard
Internet
│
├─ :80 ──► Traefik ──► HTTP→HTTPS redirect
└─ :443 ─► Traefik ──┬─► app.example.com → Next.js container
├─► blog.example.com → WordPress container
├─► docs.example.com → Nginx (static)
├─► stats.example.com → Grafana (+ Authelia 2FA)
├─► auth.example.com → Authelia
├─► status.example.com → Uptime Kuma
├─► analytics.example.com → Umami
├─► auto.example.com → n8n (+ Authelia 2FA)
├─► db.example.com → Adminer (+ Authelia 2FA)
└─► notify.example.com → ntfy
┌─────────────┐ ┌──────────────┐ ┌────────────────┐
│ web │ │ database │ │ monitoring │
│ │ │ │ │ │
│ Traefik │ │ MariaDB │ │ Prometheus │
│ Next.js │ │ PostgreSQL │ │ Loki │
│ Nginx │ │ Redis │ │ Alloy │
│ WordPress │◄───►│ │ │ Graphite │
│ Authelia │ │ │ │ │
│ Umami │◄───►│ │ │ │
│ Grafana │ │ │◄───►│ │
│ ... │ └──────────────┘ └────────────────┘
└─────────────┘
Three Docker networks ensure containers only communicate with what they need:
- web - Public-facing services + Traefik
- database - Database servers + their clients only
- monitoring - Metrics/logs pipeline (not public-facing)
# SSH into your fresh Ubuntu 24.04 server as root
ssh root@your-server-ip
# Download and run the bootstrap script
curl -O https://raw.githubusercontent.com/youruser/server-example/main/scripts/bootstrap.sh
chmod +x bootstrap.sh
./bootstrap.shThe bootstrap script configures:
- System packages, timezone, locale
- Non-root
appuserservice account with sudo - SSH hardening (key-only, no root login)
- UFW firewall (ports 22, 80, 443 only)
- Fail2ban (3 attempts = 1 hour ban)
- Kernel & network tuning for high traffic
- Docker CE + Compose
- Automatic security updates
- NTP time sync, swap, misc hardening
# SSH as appuser
ssh appuser@your-server-ip
# Clone the repo
git clone https://github.com/youruser/server-example.git ~/server
cd ~/server
# Create your .env
cp .env.example .env
# Generate passwords for each service
openssl rand -base64 24 # For passwords
openssl rand -hex 32 # For secrets/keys
# Edit .env with your values
nano .envmake authelia-setup # Generates secrets
make authelia-password # Creates password hash for users.ymlEdit authelia/config/users.yml with your user and the generated hash.
make upOr for a full pull + build + start:
bash scripts/start.shmake ps # Check all containers are running
make logs # Tail all logs.
├── docker-compose.yml # All services defined here
├── .env.example # Template for environment variables
├── Makefile # Common operations (start, backup, logs...)
│
├── traefik/
│ ├── traefik.yml # Traefik static config
│ └── config/
│ └── middlewares.yml # Security headers, rate limiting
│
├── authelia/
│ └── config/
│ └── configuration.yml # SSO/2FA configuration
│
├── monitoring/
│ ├── loki-config.yml # Log aggregation config
│ ├── alloy/
│ │ └── config.alloy # Metrics & log collector
│ ├── prometheus/
│ │ └── prometheus.yml # Metrics scraping config
│ └── grafana/
│ ├── dashboards/ # Pre-built JSON dashboards
│ └── provisioning/ # Auto-provisioned datasources
│
├── sites/
│ ├── blog/ # Next.js app (source via CI/CD)
│ ├── static-site/
│ │ └── nginx.conf # Static site Nginx config
│ ├── wordpress-1/
│ │ └── uploads.ini # PHP upload limits
│ └── wordpress-2/
│ └── uploads.ini
│
├── wordpress/
│ └── Dockerfile # WordPress + phpredis extension
│
├── scripts/
│ ├── bootstrap.sh # Server initial setup
│ ├── start.sh # Stack start/update
│ ├── backup.sh # DB dumps + offsite sync
│ ├── init-wordpress-dbs.sh # MariaDB init (multi-DB)
│ └── init-postgres-dbs.sh # PostgreSQL init (multi-DB)
│
├── github-actions/
│ ├── ci-nextjs-app.yml # CI/CD: Next.js app
│ └── ci-static-site.yml # CI/CD: static site
│
└── ntfy/
└── server.yml # Push notification config
Both MariaDB and PostgreSQL are configured to host multiple databases. Init scripts (scripts/init-*-dbs.sh) automatically create databases, users, and monitoring access on first startup.
The custom WordPress Dockerfile installs phpredis. Each WordPress site uses a separate Redis database index and key prefix to avoid collisions:
# Site 1: Redis DB 0, prefix "site1_"
# Site 2: Redis DB 1, prefix "site2_"Services like Grafana, Adminer, Traefik dashboard, and n8n are protected by Authelia's ForwardAuth middleware, requiring username + TOTP 2FA:
labels:
- "traefik.http.routers.myservice.middlewares=authelia@docker"Host/Container Metrics ──► Alloy ──► Prometheus ──► Grafana
Docker Logs ─────────────► Alloy ──► Loki ────────► Grafana
Alloy replaces the need for separate node_exporter, cAdvisor, and Promtail containers.
scripts/backup.sh dumps all databases and key data, then syncs to an offsite storage box via rsync/SSH:
- Local backups: kept 7 days
- Remote backups: kept 30 days
- Runs daily at 3:00 AM via cron (
make backup-setup)
GitHub Actions workflows in github-actions/ show the pattern:
- Build in CI
- Rsync source/artifacts to server
docker compose up -d --buildon server
| Subdomain | Service | Auth |
|---|---|---|
app.example.com |
Next.js website | Public |
blog.example.com |
WordPress | Public |
docs.example.com |
Static site (Nginx) | Public |
auth.example.com |
Authelia SSO | Public |
stats.example.com |
Grafana | Authelia 2FA |
status.example.com |
Uptime Kuma | Public |
analytics.example.com |
Umami | Public |
auto.example.com |
n8n | Authelia 2FA |
db.example.com |
Adminer | Authelia 2FA |
notify.example.com |
ntfy | Public |
traefik.example.com |
Traefik Dashboard | Authelia 2FA |
home.example.com |
Homepage Dashboard | Authelia 2FA |
Tested on a dedicated server with:
- CPU: Intel Core i5-13500 (6P+8E cores, 20 threads)
- RAM: 64 GB DDR4 ECC
- Storage: 2x 512 GB NVMe SSD
- OS: Ubuntu 24.04 LTS
This setup comfortably runs 15+ containers with plenty of headroom.
MIT