initial commit

This commit is contained in:
Tim Lappe 2025-06-02 08:34:04 +02:00
commit 15a8c448cc
4 changed files with 95 additions and 0 deletions

37
README.md Normal file
View File

@ -0,0 +1,37 @@
# Dev Proxy with Traefik
This project sets up a local development environment with Traefik as a reverse proxy.
## What is Traefik?
Traefik is a modern reverse proxy and load balancer that automatically discovers your services and configures itself accordingly. This makes it perfect for containerized environments.
## Getting Started
1. Ensure Docker and Docker Compose are installed on your system
2. Start the services:
```
docker-compose up -d
```
3. Access the Traefik dashboard at: http://traefik.localhost:8080
4. Access the example app at: http://app.localhost
## Configuration
The main configuration is in the `docker-compose.yml` file and additional Traefik configuration is in the `traefik/config/` directory.
To add a new service to be proxied by Traefik:
1. Add a new service to the docker-compose.yml
2. Add the appropriate Traefik labels to the service
3. Restart the containers with `docker-compose up -d`
## Example Labels
```yaml
labels:
- "traefik.enable=true"
- "traefik.http.routers.myservice.rule=Host(`myservice.localhost`)"
- "traefik.http.routers.myservice.entrypoints=web"
- "traefik.http.services.myservice.loadbalancer.server.port=8080"
```

32
docker-compose.yml Normal file
View File

@ -0,0 +1,32 @@
version: '3'
services:
# Traefik - the reverse proxy and load balancer
traefik:
image: traefik:latest
restart: always
ports:
- "88:88" # HTTP
- "5432:5432" # Postgres
- "3306:3306" # MySQL
- "8081:8080" # Dashboard
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./traefik/config:/etc/traefik
command:
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.file.directory=/etc/traefik"
labels:
- "traefik.enable=true"
- "traefik.http.routers.dashboard.rule=Host(`traefik.localhost`)"
- "traefik.http.routers.dashboard.service=api@internal"
- "traefik.http.routers.dashboard.entrypoints=web"
networks:
- proxy
networks:
proxy:
driver: bridge
name: proxy

1
traefik/config/acme.json Normal file
View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1,25 @@
global:
checkNewVersion: true
sendAnonymousUsage: false
api:
insecure: true
dashboard: true
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
file:
directory: "/etc/traefik"
watch: true
entryPoints:
web:
address: ":88"
postgres:
address: ":5432"
mysql:
address: ":3306"