5
#Traefik 配置http自动跳转到https
source link: https://xmanyou.com/traefik-redirect-http-request-to-https-on-same-entrypoint/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
18 August 2021
/ traefik
#Traefik 配置http自动跳转到https
配置http与https使用相同端口
根据Traefik的文档,从v2开始,要在同一个端口上同时接收http和https请求,需要配置2个router
routers:
my-service-https:
entryPoints:
- web
service: myservice
rule: "Host(`myhost`)"
tls: {}
priority: 1
my-service-http:
entryPoints:
- web
service: myservice
rule: "Host(`myhost`)"
priority: 1
配置http自动跳转中间件
如果要让http请求自动重定向到https,需要配置一个redirectScheme插件
http:
middlewares:
redirect-https:
redirectScheme:
scheme: https
permanent: true
配置http路由使用重定向插件
my-service-http:
entryPoints:
- web
service: myservice
rule: "Host(`myhost`)"
middlewares:
- redirect-https
priority: 1
阿斌
Read more posts by this author.
扫一扫关注微信公众号:耿直的IT男阿斌
聊一聊IT男眼中的世界
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK