Windows Sandbox provides an isolated, lightweight, disposable virtual machine environment built natively into Windows 11 Pro and Enterprise editions. For web developers, DevOps engineers, and security researchers, running local ingress proxies alongside community discussion platforms inside Windows Sandbox provides a safe testing ground. When configuring local containerised services such as PunBB forum software behind a Traefik edge reverse proxy, managing dynamic TLS certificates and client rate limiting requires automated provisioning. This tutorial explains how to deploy Traefik, generate local TLS certificates, and enforce rate limiting for PunBB using Windows Sandbox configuration XML (WSB) files.
Architecture of the Windows Sandbox Automation Workflow
Every Windows Sandbox session starts from a clean Windows 11 base image, discarding all state upon shutdown. To run a functional Traefik and PunBB deployment automatically, the host machine must inject configuration files through mapped folders and trigger a bootstrapping script upon sandbox initialisation.
Windows Sandbox configuration files (.wsb) use XML syntax to mount host directories into the container and execute custom PowerShell scripts via <LogonCommand>. By scripting Traefik’s file-based dynamic configuration provider inside the sandbox, developers can test strict rate limiting and SSL termination without altering the host machine’s network stack or registry.
Authoring the Windows Sandbox XML Configuration File
Create a dedicated deployment directory on your host machine, such as C:\SandboxEnvironments\TraefikPunBB, and save the following configuration file as PunBBSandbox.wsb:
<Configuration>
<VGpu>Enable</VGpu>
<Networking>Enable</Networking>
<MappedFolders>
<MappedFolder>
<HostFolder>C:\SandboxEnvironments\TraefikPunBB</HostFolder>
<SandboxFolder>C:\TraefikPunBB</SandboxFolder>
<ReadOnly>false</ReadOnly>
</MappedFolder>
</MappedFolders>
<LogonCommand>
<Command>powershell.exe -ExecutionPolicy Bypass -NoExit -File C:\TraefikPunBB\bootstrap_punbb.ps1</Command>
</LogonCommand>
</Configuration>
Configuring Traefik Dynamic TLS and Rate Limiting
Inside the shared folder on the host machine, author the Traefik dynamic configuration file named traefik_dynamic.yml. This file configures the rate-limiting middleware and routes inbound HTTPS requests to the PunBB service:
http:
routers:
punbb-router:
rule: "Host(`punbb.local`)"
service: punbb-service
entryPoints:
- websecure
middlewares:
- punbb-ratelimit
tls: {}
middlewares:
punbb-ratelimit:
rateLimit:
average: 60
burst: 120
period: 1m
sourceCriterion:
ipStrategy:
depth: 1
services:
punbb-service:
loadBalancer:
servers:
- url: "http://127.0.0.1:80"
tls:
certificates:
- certFile: "C:/TraefikPunBB/certs/local-cert.pem"
keyFile: "C:/TraefikPunBB/certs/local-key.pem"
Authoring the PowerShell Provisioning Script
Save the accompanying automation script as bootstrap_punbb.ps1 in the shared folder. This script installs Chocolatey, downloads Traefik and OpenSSL, generates local self-signed TLS certificates, and launches the proxy services inside the sandbox:
# bootstrap_punbb.ps1 - Automated sandbox provisioning
Set-ExecutionPolicy Bypass -Scope Process -Force
Write-Host "Installing packages via Chocolatey..." -ForegroundColor Cyan
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
choco install traefik openssl -y
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
# Generate self-signed TLS certificates for local domain
$certDir = "C:\TraefikPunBB\certs"
if (!(Test-Path $certDir)) { New-Item -ItemType Directory -Path $certDir -Force }
openssl req -x509 -nodes -days 365 -newkey rsa:2048 `
-keyout "$certDir\local-key.pem" `
-out "$certDir\local-cert.pem" `
-subj "/CN=punbb.local"
# Update local hosts file
Add-Content -Path "C:\Windows\System32\drivers\etc\hosts" -Value "127.0.0.1 punbb.local"
# Launch Traefik in background
Start-Process "traefik" -ArgumentList "--configFile=C:\TraefikPunBB\traefik_dynamic.yml" -WindowStyle Minimized
Write-Host "Windows Sandbox Traefik & PunBB environment initialized successfully." -ForegroundColor Green
Testing and Validating Rate Limiting
Double-click PunBBSandbox.wsb on your Windows 11 host. Windows Sandbox will launch, map the folder, and run the PowerShell bootstrap script. Once initialized, test the rate-limiting middleware by executing rapid curl requests from within the sandbox terminal:
1..125 | ForEach-Object {
curl.exe -k -s -o /dev/null -w "%{http_code}`n" https://punbb.local/
}
The first hundred and twenty requests will return HTTP 200 OK. Subsequent requests exceeding the average threshold will receive HTTP 429 Too Many Requests, verifying that Traefik’s dynamic middleware correctly throttles abusive traffic before it reaches the backend container.