| .gitea/workflows | ||
| db | ||
| docs | ||
| infra | ||
| services | ||
| tests | ||
| .deployment-checklist.txt | ||
| .env.example | ||
| .env.prod.example | ||
| .gitignore | ||
| build-multiarch.sh | ||
| build-windows-agent.sh | ||
| deploy-server.sh | ||
| DEPLOY.md | ||
| DEPLOYMENT_SUMMARY.md | ||
| docker-compose.prod.yml | ||
| docker-compose.yml | ||
| Makefile | ||
| QUICKSTART_PRODUCTION.md | ||
| README.md | ||
| setup-gitea-repo.sh | ||
| setup-windows-client.ps1 | ||
| START_HERE.md | ||
| test_full_flow.sh | ||
| WINDOWS_SETUP.md | ||
WireGuard Port Forwarding Platform (MVP)
A self-hosted platform for managing dynamic port forwarding through WireGuard tunnels. Clients connect via WireGuard VPN and can expose local services through the server's public IP.
🎯 Features
- WireGuard-based tunneling - Secure, modern VPN protocol
- Dynamic port mapping - Map public ports to client services (TCP/UDP)
- Web Admin UI - React-based dashboard for management
- REST API - Full-featured API with JWT authentication
- Role-based access - Admin and user roles with proper isolation
- Real-time config updates - Nginx stream proxy with automatic reloading
- Multi-architecture - Supports linux/amd64, linux/arm64, and Windows agents
🏗️ Architecture
┌─────────┐ ┌────────────┐ ┌──────────────┐
│ Admin │─────▶│ Caddy │─────▶│ FastAPI │
│ UI │ │ (Port 83) │ │ (Port 8080) │
└─────────┘ └────────────┘ └──────────────┘
│
▼
┌────────────┐ ┌──────────────┐
│ Controller │◀─────│ PostgreSQL │
│ (Config) │ │ Database │
└────────────┘ └──────────────┘
│
▼
┌────────────┐ ┌──────────────┐
Internet │ Nginx │◀────▶│ WireGuard │
Traffic ─────▶│ Stream │ │ Server │
│ (20000- │ │ (51820/udp) │
│ 20100) │ └──────────────┘
└────────────┘ ▲
│
│ WG Tunnel
▼
┌──────────────┐
│ Agent │
│ (Client) │
└──────────────┘
│
▼
[Local Services]
🚀 Quick Start
📌 For Production Deployment: See QUICKSTART_PRODUCTION.md for VPS deployment with Traefik + Windows agent
Local Development
Prerequisites
- Docker & Docker Compose
- Linux host (for server components)
- Supported architectures: linux/amd64, linux/arm64
- Ports available: 83 (UI), 51820 (WireGuard), 20000-20100 (forwarding)
For Windows agents: See WINDOWS_SETUP.md for client setup
1. Clone and Configure
git clone <repo>
cd wg-gaming-tunnel
# Copy environment template
cp .env.example .env
# Edit credentials (required)
nano .env
# Set ADMIN_EMAIL and ADMIN_PASSWORD
# Optionally change JWT_SECRET
2. Build and Start
# Build all services
make build
# Start stack
make up
# Or manually:
docker compose up -d
3. Access Admin UI
Open http://localhost:83 and login with credentials from .env:
- Email:
admin@example.com(or your custom value) - Password:
admin123(or your custom value)
4. Verify Services
# Check all services are running
docker compose ps
# View logs
docker compose logs -f
# Run skeleton tests
make test
📖 Usage
Creating a Client
-
In Admin UI:
- Navigate to Dashboard
- Click "New Client"
- Enter client name
- Click "Create"
-
Set WireGuard Key:
- Generate client key pair:
wg genkey | tee client_private.key | wg pubkey > client_public.key - In UI, click "Set Key" for the client
- Paste contents of
client_public.key - System assigns WireGuard IP automatically (e.g.,
10.10.0.3)
- Generate client key pair:
-
Note assigned IP - You'll need this for WireGuard client config
Creating Port Mappings
- In Admin UI, go to "Mappings" section
- Click "New Mapping"
- Select client
- Choose protocol (TCP/UDP)
- Set public port (20000-20100)
- Set target port (port on client machine)
- Click "Create"
Mapping propagates to Nginx within ~2 seconds.
Connecting a Client (Manual)
Note: Agent implementation is pending. For now, manual WireGuard setup:
- Create WireGuard config on client:
[Interface]
PrivateKey = <contents of client_private.key>
Address = <assigned IP from UI>/24
DNS = 1.1.1.1
[Peer]
PublicKey = <server public key - see below>
Endpoint = <server IP>:51820
AllowedIPs = 10.10.0.0/24
PersistentKeepalive = 25
- Get server public key:
docker compose exec wireguard cat /etc/wireguard/server_public.key
- Start WireGuard on client:
wg-quick up wg0
- IMPORTANT: Manually add peer to server (until agent is implemented):
docker compose exec wireguard wg set wg0 peer <CLIENT_PUBKEY> allowed-ips <CLIENT_IP>/32
🛠️ Development
Project Structure
wg-gaming-tunnel/
├── db/ # Database initialization
│ └── init.sql # Schema, indexes, constraints
├── docs/ # Documentation
│ ├── ARCHITECTURE.md # System design
│ └── SECURITY.md # Security considerations
├── infra/ # Infrastructure services
│ ├── caddy/ # Reverse proxy
│ ├── nginx-stream/ # TCP/UDP proxy
│ │ ├── controller/ # Config generator
│ │ └── templates/ # Nginx config templates
│ └── wireguard-server/ # WireGuard userspace
├── services/ # Application services
│ ├── agent/ # Client agent (Go) [INCOMPLETE]
│ ├── api/ # FastAPI backend
│ │ └── app/
│ │ ├── routers/ # API endpoints
│ │ ├── models.py # SQLAlchemy models
│ │ └── schemas.py# Pydantic schemas
│ └── ui/ # React admin UI
│ └── src/
│ ├── components/
│ ├── api.js # API client
│ └── App.jsx
├── tests/ # E2E tests
└── docker-compose.yml # Service orchestration
API Endpoints
Authentication:
POST /auth/login- Get JWT tokens
Clients:
GET /clients- List own clientsPOST /clients- Create clientPOST /clients/{id}/keys- Set WireGuard public key
Mappings:
GET /mappings- List own mappingsPOST /mappings- Create mappingPATCH /mappings/{id}- Enable/disableDELETE /mappings/{id}- Delete mapping
Running Tests
# Skeleton tests (health checks)
make test
# Manual API test
TOKEN=$(curl -s -X POST http://localhost:83/api/auth/login \
-H 'Content-Type: application/json' \
-d '{"email":"admin@example.com","password":"admin123"}' | jq -r '.access_token')
curl -H "Authorization: Bearer $TOKEN" http://localhost:83/api/clients
Database Access
# Connect to database
docker compose exec db psql -U app -d app
# Check tables
docker compose exec db psql -U app -d app -c "\dt"
# View clients
docker compose exec db psql -U app -d app -c "SELECT * FROM clients;"
⚙️ Configuration
Environment Variables
See .env.example for all options. Key variables:
| Variable | Default | Description |
|---|---|---|
ADMIN_EMAIL |
- | Admin user email (required) |
ADMIN_PASSWORD |
- | Admin user password (required) |
JWT_SECRET |
changeme |
JWT signing secret (change in prod!) |
JWT_EXP_MINUTES |
60 |
Access token expiration |
WG_SUBNET |
10.10.0.0/24 |
WireGuard VPN subnet |
WG_PORT |
51820 |
WireGuard UDP port |
Ports
| Service | Internal | External | Protocol |
|---|---|---|---|
| Caddy (UI) | 80 | 83 | HTTP |
| Caddy (HTTPS) | 443 | 448 | HTTPS |
| API | 8080 | - | HTTP (internal) |
| WireGuard | 51820 | 51820 | UDP |
| Nginx Stream | 20000-20100 | 20000-20100 | TCP/UDP |
📝 TODO / Known Issues
See PROJECT_AUDIT.md for comprehensive status.
Critical Missing:
- ✅ API implementation - DONE
- ✅ Admin UI - DONE
- ⚠️ WireGuard peer management (no automatic peer addition)
- ⚠️ Agent implementation (placeholder only)
- ⚠️ Full E2E tests (skeleton only)
Next Steps:
- Implement WireGuard peer management in controller
- Complete agent (WG setup, registration, keepalive)
- Write full E2E tests with traffic validation
🔒 Security
- JWT-based authentication with bcrypt password hashing
- Role-based access control (admin vs user)
- WireGuard for encrypted tunnels
- PostgreSQL for data persistence with proper constraints
- No secrets in git (use
.envfor credentials)
Production Considerations:
- Change default
JWT_SECRET - Use strong admin password
- Enable TLS in Caddy
- Add rate limiting
- Run services as non-root
- Regular security updates
🏗️ Multi-Architecture Support
This project supports multiple platforms:
Server Components (linux/amd64, linux/arm64):
- Raspberry Pi 4/5, AWS Graviton, Apple Silicon
- Standard x86_64 servers
Agent (linux/amd64, linux/arm64, windows/amd64, windows/arm64):
- Works on any platform including Windows desktops/laptops
Build Multi-Arch Images
# Build for all architectures
./build-multiarch.sh
# Build Windows agent binary
./build-windows-agent.sh amd64
See MULTIARCH.md for detailed instructions.
📚 Documentation
Production Deployment
- QUICKSTART_PRODUCTION.md - 10-minute deployment guide (VPS + Windows)
- DEPLOY.md - Complete production deployment guide
- WINDOWS_SETUP.md - Windows agent setup guide
Development & Architecture
docs/ARCHITECTURE.md- System design and data flowdocs/SECURITY.md- Security model and threat analysisMULTIARCH.md- Multi-architecture deployment guideGITEA_SETUP.md- Gitea repository and CI/CD setupGITEA_QUICKSTART.md- Quick Gitea setup guideTODO.md- Development backlogPROJECT_AUDIT.md- Current status and issues
🤝 Contributing
- Check
TODO.mdfor open tasks - Follow existing code style
- Add tests for new features
- Update documentation
📄 License
[Add your license]
🙋 Support
For issues or questions, see documentation in docs/ or review PROJECT_AUDIT.md for known issues.