How to Configure Windows Sandbox Local Traefik ErrorPages Middleware via XML in Windows 11

Testing branded error page interception and custom HTTP status redirects without polluting production ingress networks is essential for delivering polished user experiences. Traefik’s ErrorPages middleware intercepts upstream backend error codes (e.g. 500, 502, 503) and serves custom HTML payloads seamlessly. Windows Sandbox on Windows 11 provides an isolated, disposable container for validating these error-handling workflows.

Why Test Error Pages in Windows Sandbox

Traefik’s ErrorPages middleware re-routes HTTP error responses to a designated error-handling microservice or static handler. Testing within Windows Sandbox ensures that fault injection, network disconnection tests, and mock HTTP 500 responses remain completely isolated from the host workstation.

Authoring the Windows Sandbox WSB XML

Save the following XML document as TraefikErrorSandbox.wsb on your Windows 11 machine:

<Configuration>
  <VGpu>Default</VGpu>
  <Networking>Default</Networking>
  <MappedFolders>
    <MappedFolder>
      <HostFolder>C:\TraefikErrorLab</HostFolder>
      <SandboxFolder>C:\TraefikErrorLab</SandboxFolder>
      <ReadOnly>true</ReadOnly>
    </MappedFolder>
  </MappedFolders>
  <LogonCommand>
    <Command>powershell.exe -ExecutionPolicy Bypass -NoExit -File C:\TraefikErrorLab\setup-errorpages.ps1</Command>
  </LogonCommand>
</Configuration>

PowerShell Deployment Bootstrapper

Save the bootstrapping script as C:TraefikErrorLabsetup-errorpages.ps1:

Write-Host "Setting up Traefik ErrorPages Lab..." -ForegroundColor Cyan

$Dir = "C:Traefik"
New-Item -ItemType Directory -Force -Path $Dir | Out-Null

$ZipUrl = "https://github.com/traefik/traefik/releases/download/v3.0.0/traefik_v3.0.0_windows_amd64.zip"
Invoke-WebRequest -Uri $ZipUrl -OutFile "$Dir	raefik.zip"
Expand-Archive -Path "$Dir	raefik.zip" -DestinationPath $Dir -Force

$Config = @"
http:
  middlewares:
    custom-errorpage:
      errors:
        status:
          - "500-599"
        service: "error-service"
        query: "/error.html"
  routers:
    app-router:
      rule: "PathPrefix(`/app`)"
      middlewares:
        - "custom-errorpage"
      service: "failing-service"
  services:
    failing-service:
      loadBalancer:
        servers:
          - url: "http://127.0.0.1:9999" # unreachable port to trigger 502
    error-service:
      loadBalancer:
        servers:
          - url: "http://127.0.0.1:8080"
"@

Set-Content -Path "$Dirdynamic_conf.yml" -Value $Config
Write-Host "Traefik ErrorPages Middleware Configured for 5xx Interception." -ForegroundColor Green

Verifying Custom Error Responses

Double-click the .wsb file to boot the sandbox. Send an HTTP request to http://127.0.0.1/app using curl. Verify that Traefik intercepts the gateway timeout/connection failure and serves the custom error page from the fallback error service. Closing the sandbox purges all temporary files cleanly.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.