Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用docker标签将Traefik http重定向到https_Docker_Traefik - Fatal编程技术网

使用docker标签将Traefik http重定向到https

使用docker标签将Traefik http重定向到https,docker,traefik,Docker,Traefik,我在swarm模式下使用traefik作为docker服务。 Traefik接受一些标签来配置如何处理docker容器并为其创建代理 我可以在docker服务中定义标签traefik.frontend.entryPoints=https,以覆盖traefikdefaultEntryPoints,但用户需要使用https发出请求。我想公开入口点,http和https,但如果用户使用http发出请求,Traefik会将其重定向到https 是否可以使用entryPoints.http.redirec

我在swarm模式下使用traefik作为docker服务。 Traefik接受一些标签来配置如何处理docker容器并为其创建代理

我可以在docker服务中定义标签
traefik.frontend.entryPoints=https
,以覆盖traefik
defaultEntryPoints
,但用户需要使用
https
发出请求。我想公开入口点,
http
https
,但如果用户使用
http
发出请求,Traefik会将其重定向到
https

是否可以使用
entryPoints.http.redirect
作为docker标签来强制重定向某些特定服务?我不想在
traefik.toml
文件中设置它,因为它将应用于所有服务,我只希望它应用于一些服务,而不是所有服务


认为

仍然是一个悬而未决的问题->现在不可能

由于引入,现在可以执行以下操作:

labels:
- "traefik.frontend.redirect.entryPoint=https"

我对选择的问题(这是正确的)有点纠结,所以这里有更多的信息

如果您遵循Traefik文档中的步骤,则最终会得到以下配置:

[entryPoints]
  [entryPoints.http]
  address = ":80"
    [entryPoints.http.redirect]
    entryPoint = "https"
  [entryPoints.https]
  address = ":443"
  [entryPoints.https.tls]
entryPoints.http
中有
entryPoints.http.redirect
规则,它告诉Traefik实现重定向到https

如果要选择应实现重定向的服务,首先需要禁用此全局行为:

[entryPoints]
  [entryPoints.http]
  address = ":80"
  [entryPoints.https]
  address = ":443"
  [entryPoints.https.tls]
此时,您可以将标签应用于要重定向的服务:

labels:
  ...
  - "traefik.frontend.redirect.entryPoint=https"
我希望这有帮助