安装traefik流量监控与反向代理
程序员文章站
2022-04-18 16:43:18
...
官方文档:https://docs.traefik.io/v2.0/getting-started/quick-start
配置文件详解:https://docs.traefik.cn/toml#global-configuration
1. 创建 traefik.toml配置文件
[global]
checkNewVersion = true
sendAnonymousUsage = true
[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.websecure]
address = ":443"
# Enable API and dashboard
[api]
insecure = false
dashboard = false
2. docker启动
docker run -dit \
--name traefik \
-p 8600:8080 \
-p 8601:80 \
-v $PWD/traefik.toml:/etc/traefik/traefik.toml \
traefik
3. 浏览器访问
浏览器访问 http://ip:8600 即可看到页面
4. 反向代理与负载均衡
向traefik.toml 配置文件追加下列配置
[backends]
[backends.backend1]
[backends.backend1.circuitbreaker]
expression = "NetworkErrorRatio() > 0.5"
[backends.backend1.servers.server1]
url = "http://pibigstar.com"
weight = 2
[backends.backend1.servers.server2]
url = "http://pibigstar.com"
weight = 1
上一篇: SSH+ExtJS项目,当session过期时跳转到登陆界面
下一篇: JVM字节码技术