0

我已经尝试启动并运行了两天,但一些简单的 HTTP -> HTTPs 重定向不起作用!:(

非常简单的用例:

whoami.my-example-domain.com:80 => 重定向到 whoami.my-example-domain.com:443 然后 traefik 在内部重定向到我的 whoami 服务 docker 容器的 :80。

这是 docker-compose.yml

version: "3"
services:
  reverse-proxy:
image: traefik:alpine
command:
  - --logLevel=WARN
  - --defaultentrypoints=http,https
  - --entrypoints=Name:http Address::80 Redirect.EntryPoint:https
  - --entrypoints=Name:https Address::443 TLS
  - --acme
  - --acme.email=myemail@gmail.com
  - --acme.storage=acme.json
  - --acme.entryPoint=https
  - --acme.httpChallenge.entryPoint=http
  - --acme.OnHostRule=true
  - --acme.onDemand=false
  - --acme.acmeLogging=true
  - --docker
  - --docker.watch
  - --docker.exposedbydefault=false
  - --docker.domain=docker.localhost
restart: always
networks:
  - web
ports:
  - "80:80"     # The HTTP port
  - "443:443"   # The HTTPS port
volumes:
  - /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
  - /opt/data/traefik/acme.json:/acme.json
  whoami:
image: containous/whoami  # A container that exposes an API to show its IP address
labels:
  - "traefik.enable=true"
  - "traefik.frontend.rule=Host:whoami.some-example-domain.com"
  - "traefik.port=80"
  - "traefik.frontend.entryPoints=http"
networks:
  web:
    external: true

当我现在调用http://whoami.some-example-domain.com(这只是一个演示域并且不起作用)=> 它重定向到 HTTPs ......这很酷,但随后它抛出了著名的“ 404 页面未找到” traefik 标准错误。

如果已经尝试为容器设置以下标签:

  • “traefik.port=80”
  • “traefik.frontend.entryPoints=http”

那也没有用。

任何帮助,将不胜感激!提前致谢!

问候,

萨沙

4

1 回答 1

2

您必须删除traefik.frontend.entryPoints(链接到defaultentrypoints)或使用traefik.frontend.entryPoints=http,https

version: "3"

services:
  reverse-proxy:
    image: traefik:v1.7.8
    command:
      - --logLevel=WARN
      - --defaultentrypoints=http,https
      - --entrypoints=Name:http Address::80 Redirect.EntryPoint:https
      - --entrypoints=Name:https Address::443 TLS
      - --acme
      - --acme.email=myemail@gmail.com
      - --acme.storage=acme.json
      - --acme.entryPoint=https
      - --acme.httpChallenge.entryPoint=http
      - --acme.OnHostRule=true
      - --acme.onDemand=false
      - --acme.acmeLogging=true
      - --docker
      - --docker.exposedbydefault=false
      - --docker.domain=some-example-domain.com
    restart: always
    networks:
      - web
    ports:
      - "80:80"     # The HTTP port
      - "443:443"   # The HTTPS port
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
      - /opt/data/traefik/acme.json:/acme.json
  whoami:
    image: containous/whoami  # A container that exposes an API to show its IP address
    labels:
      - "traefik.enable=true"
      - "traefik.frontend.rule=Host:some-example-domain.com"
    networks:
     - web

networks:
  web:
    external: true
于 2019-02-08T11:41:44.663 回答