Traefik-简单成功案例
程序员文章站
2022-04-18 16:43:30
...
1.创建docker-compose文件
部署机器ip1
version: '3'
services:
reverse-proxy:
image: harbor.yundasys.com/base/traefik:v2.1
ports:
- "8081:80" # traefik暴露的http端口
- "8080:8080" # webUI暴露的端口(必须制定--api.insecure=true才可以访问)
- "6601:6601" # 暴露出来供访问的端口
volumes:
- traefik-config:/etc/traefik
volumes:
traefik-config:
2.在/etc/traefik/下添加traefik.yml静态文件
#static configuration
api:
dashboard: true
insecure: true
providers:
file:
filename: "/etc/traefik/dynamic-conf.yml"
watch: true
entryPoints:
web:
address: ":80"
web-secure:
address: ":443"
traefik:
address: ":8080"
cluster-6601:
address: ":6601"
3.在/etc/traefik/下添加dynamic-conf动态文件
#dynamic configuration
tcp:
routers:
cluster-router-6601:
entryPoints:
- "cluster-6601"
rule: "HostSNI(`*`)"
service: "cluster-service-6601"
services:
cluster-service-6601:
loadBalancer:
servers:
- address: "10.19.*.210:6601"
- address: "10.19.*.210:6602"
- address: "10.19.*.210:6603"
4.启动traefik后,访问客户端和redis
http://ip1:8080/,如图所示链接已建立
redis客户端访问 ip1:6601
测试完成,下一版出动态配置