initial commit
This commit is contained in:
commit
15a8c448cc
37
README.md
Normal file
37
README.md
Normal 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
32
docker-compose.yml
Normal 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
1
traefik/config/acme.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
||||
25
traefik/config/traefik.yml
Normal file
25
traefik/config/traefik.yml
Normal 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"
|
||||
Loading…
x
Reference in New Issue
Block a user