From 15a8c448cc54025d4325bec51fbdf5e76e1fd3f1 Mon Sep 17 00:00:00 2001 From: Tim Lappe Date: Mon, 2 Jun 2025 08:34:04 +0200 Subject: [PATCH] initial commit --- README.md | 37 +++++++++++++++++++++++++++++++++++++ docker-compose.yml | 32 ++++++++++++++++++++++++++++++++ traefik/config/acme.json | 1 + traefik/config/traefik.yml | 25 +++++++++++++++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 README.md create mode 100644 docker-compose.yml create mode 100644 traefik/config/acme.json create mode 100644 traefik/config/traefik.yml diff --git a/README.md b/README.md new file mode 100644 index 0000000..a25d50c --- /dev/null +++ b/README.md @@ -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" +``` \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2108fff --- /dev/null +++ b/docker-compose.yml @@ -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 diff --git a/traefik/config/acme.json b/traefik/config/acme.json new file mode 100644 index 0000000..1868abf --- /dev/null +++ b/traefik/config/acme.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/traefik/config/traefik.yml b/traefik/config/traefik.yml new file mode 100644 index 0000000..e11f665 --- /dev/null +++ b/traefik/config/traefik.yml @@ -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" \ No newline at end of file