
traefik
- traefik은 서비스로 들어오는 요청들을 가로채서, 적절한 인스턴스에 분배시켜주는 오픈소스 플랫폼이다.
→ Edge Router
- 시스템을 대신하여 요청을 받고, 어떤 구성요소가 해당 요청을 처리하는지 알아낸다. 서비스가 배포되면 이를 즉시 감지하고, 라우팅 규칙을 실시간으로 업데이트한다.
→ Auto Service Discovery
Tutorial

docker-compose.yaml (traefik:v3.0)
version: '3'
services:
reverse-proxy:
# The official v3 Traefik docker image
image: traefik:v3.0
# Enables the web UI and tells Traefik to listen to docker
command: --api.insecure=true --providers.docker
ports:
# The HTTP port
- "80:80"
# The Web UI (enabled by --api.insecure=true)
- "8080:8080"
volumes:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock
- 바이너리
- trafik.toml (config)
# defaultEntryPoints = ["http", "https"]
[entryPoints]
[entryPoints.http]
address = ":7777"
[api]
dashboard = true
insecure = true
[providers]
[providers.file]
filename = "traefik.toml"
watch = true
[http]
[http.routers]
[http.routers.usermanagement]
entryPoints = ["http"]
rule = "PathPrefix(`/seedotech.usermanagement`)"
service = "usermanagement"
[http.routers.moviemanagement]
entryPoints = ["http"]
rule = "PathPrefix(`/seedotech.moviemanagement`)"
service = "moviemanagement"
# Adding a router for the Traefik dashboard
[http.routers.api]
rule = "PathPrefix(`/dashboard`)"
service = "api@internal"
entryPoints = ["http"]
[http.services]
[http.services.usermanagement.loadBalancer]
[[http.services.usermanagement.loadBalancer.servers]]
url = "http://127.0.0.1:8808"
[http.services.moviemanagement.loadBalancer]
[[http.services.moviemanagement.loadBalancer.servers]]
url = "http://127.0.0.1:8809"
./traefik --configFile=traefik.toml

- dashboard (http://localhost:8080/dashboard)
- http://localhost:7777/seedotech.moviemanagement/api/v1/movies/list 으로 요청을 보내면 http://localhost:8809/seedotech.moviemanagement/api/v1/movies/list 가 요청을 수신하는것을 확인할 수 있다.
http.routers
에서의 설정값으로 traefik이 라우팅해준다.

Middleware

- 대표적으로 다음과 같은 미들웨어 기능들이 가능한 것 같다.
- HTTP
- TCP
Adds a Path Prefix | Path Modifier | |
Adds Basic Authentication | Security, Authentication | |
Buffering | Buffers the request/response | Request Lifecycle |
Chain | Combines multiple pieces of middleware | Misc |
CircuitBreaker | Prevents calling unhealthy services | Request Lifecycle |
Limits the number of simultaneous connections. | Security, Request lifecycle | |
Limit the allowed client IPs. | Security, Request lifecycle |
Share article