1 概述
Traefik是一个基于Go语言编写的开源的云原生的边界路由器。
下载: https://github.com/containous/traefik/releases
配置:
# https://docs.traefik.io/v2.2/reference/static-configuration/file/
global:
checkNewVersion: true
sendAnonymousUsage: false
log:
level: DEBUG
# https://docs.traefik.io/v2.2/operations/api
api:
dashboard: true
insecure: true
debug: true
# https://docs.traefik.io/v2.2/routing/entrypoints
entryPoints:
http:
address: :80
mysql:
address: :3306
providers:
providersThrottleDuration: 2s
# https://docs.traefik.io/v2.2/providers/file/
file:
watch: true
filename: dynamic.yml
http:
routers:
example.test.router:
rule: Host(`example.test`)
service: example.test.service
services:
example.test.service:
loadBalancer:
servers:
- url: http://192.168.2.201:5000
healthCheck:
scheme: http
path: /
interval: 10s
timeout: 3s
tcp:
routers:
mysql.router:
entryPoints:
- mysql
rule: HostSNI(`mysql`)
service: mysql.service
services:
mysql.service:
loadBalancer:
servers:
- address: 192.168.2.201:3306