docker - Traefik 2 如何在静态配置中引用 tls 证书以在 docker-compose 文件中进行路由
问题描述
我在我的traefik_v2.yml
api:
dashboard: true
insecure: true
global: {}
providers:
providersThrottleDuration: 2s
docker:
watch: true
endpoint: unix:///var/run/docker.sock
swarmModeRefreshSeconds: 15s
file:
filename: "traefik_v2.yml"
log:
level: INFO
tls:
certificates:
- certFile: /run/secrets/cert_secret
keyFile: /run/secrets/cert_key_secret
entryPoints:
web:
address: ":80"
redirections:
entrypoint:
to: external
scheme: https
web-secure:
address: ":443"
api:
address: ":8080"
external:
address: ":10443"
现在在我的一个撰写文件中,如何将路由器 tls 配置配置为静态文件中存在的配置traefik_v2.yml
?
version: '3.4'
services:
x-authentication-app:
image: x_authentication_app_nightly:v${BUILD_NUMBER}
deploy:
labels:
- "traefik.docker.network=x-swarm-net"
- "traefik.http.routers.authenticationapp.rule=PathPrefix(`/authentication`)"
- "traefik.http.routers.authenticationapp.service=x-authentication-app"
- "traefik.http.routers.authenticationapp.entrypoints=web"
- "traefik.http.routers.authenticationapp.tls={}" // **What to say in here ? I want to use the static configurations that I created for tls in the traefik_v2.yml**
- "traefik.enable=true"
- "traefik.port=80"
replicas: 1
update_config:
parallelism: 1
delay: 10s
order: stop-first
networks:
- default
networks:
default:
external:
name: x-swarm-net
解决方案
您无需多说什么,只需设置即可traefik.http.routers.authenticationapp.tls=true
。
您还需要让端点监听端口 443:
traefik.http.routers.authenticationapp.entrypoints=web, web-secure
推荐阅读
- angular - VS 2019 解决方案构建错误,原因是导出赋值的表达式必须是环境上下文中的标识符或限定名称
- wordpress - 在插件设置中显示 WordPress 编辑器
- stripe-payments - Stripe 每次付款都会创建一个新客户
- c++ - 如何以可靠的方式将 std::vector 转换为 char **?
- c++ - clang vs gcc:使用运算符重载的函数查找
- python - Python逗号用于循环条件逗号分隔
- python - Google Cloud Storage - Python 客户端 - 获取 blob 的链接 URL
- reactjs - 使用 Material UI 向上滚动时,如何为导航添加背景颜色?
- audio - 为 WebM 视频添加静音轨道
- python-3.x - 使用来自 sql 的信息填充 Treeview?