Traefik:简单Letsencrypt HTTPS重定向到WHOAMI服务引发“404页找不到”

问题描述 投票:0回答:1

我一直试图让这个了,现在两天运行和一些简单的HTTP - > HTTPs的重定向不工作! :(

非常简单的例子:

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

这里的码头工人,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
  - [email protected]
  - --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”

这也不能工作。

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

问候,

萨沙

docker-compose traefik traefik-ingress
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
      - [email protected]
      - --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
© www.soinside.com 2019 - 2024. All rights reserved.