Run multiple apps on localhost without port conflicts using hostname-based routing.
curl -sSL https://raw.githubusercontent.com/u2i/traefik-dev-proxy/main/install.sh | bashThis installs:
- Executable:
~/.local/bin/traefik-dev-proxy - Config:
~/.local/share/traefik-dev-proxy - Docker network:
devnet
traefik-dev-proxy start # Start the proxy
traefik-dev-proxy stop # Stop the proxy
traefik-dev-proxy status # Check status
traefik-dev-proxy logs # View logs
traefik-dev-proxy uninstall # Remove completelyhttp://app.localhost:8080http://api.app.localhost:8080(wildcards work!)http://admin.app.localhost:8080
Note: HTTP-only (no HTTPS) because browsers don't support wildcard *.localhost certificates. Port 8080 is used to avoid needing privileged access for port 80.
In your docker-compose.yml:
services:
app:
networks: [appnet, devnet]
labels:
- "traefik.enable=true"
- "traefik.docker.network=devnet"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host(\`${APP_HOSTNAME}\`) || HostRegexp(\`{subdomain:[a-zA-Z0-9-]+}.${APP_HOSTNAME}\`)"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}.entrypoints=web"
- "traefik.http.services.${COMPOSE_PROJECT_NAME}.loadbalancer.server.port=4000"
networks:
devnet:
external: trueIn .env.dev:
COMPOSE_PROJECT_NAME=myapp
APP_HOSTNAME=myapp.localhost
✅ Single command install
✅ Wildcard subdomain support
✅ No port conflicts between apps
✅ Auto-resolving .localhost domains
✅ Clean uninstall
- Docker
- macOS or Linux
If port 8080 is taken, you can use a different port:
DEV_PROXY_PORT=9090 traefik-dev-proxy startThen access apps at http://app.localhost:9090
Check that:
- Your app is running and on the
devnetnetwork - The Traefik labels are correct in your docker-compose.yml
APP_HOSTNAMEmatches what you're accessing (e.g.,myapp.localhost)