首页 > 解决方案 > Traefik HTTPS 入口点配置无法通过让加密工作

问题描述

在我的 Traefik docker 容器中获取 HTTPS 入口点时遇到一些实际问题。

我试图遵循https://docs.traefik.io/user-guide/docker-and-lets-encrypt/上的指南

还尝试了来自https://docs.traefik.io/user-guide/examples/https://ian-says.com/articles/traefik-proxy-docker-lets-encrypt/和其他各种地方的各种位

它在 http 中一切正常,但 https 给了我一个连接被拒绝,并且 traefik 门户网站中没有 https 入口点处于活动状态。

当我从外部检查端口 443 时,它说它已关闭,但是没有防火墙,并且它还没有被使用(见docker ps下文),所以我只能认为 traefik 容器本身没有为 https 正确设置?

我的问题:如何让 HTTPS 在 traefik 上运行?另外,我如何查看 traefik 日志以获取更多信息?docker-compose logs -f reverse-proxy是空的

traefik.toml

defaultEntryPoints = ["https","http"]
debug = true

[entryPoints]
  [entryPoints.http]
  address = ":80"
  [entryPoints.https]
  address = ":443"
    [entryPoints.https.tls]

[acme]
email = "email@domain.com"
storage = "/home/project/acme.json"
caServer = "https://acme-staging-v02.api.letsencrypt.org/directory"
entryPoint = "https"
  [acme.httpChallenge]
  entryPoint = "http"

[[acme.domains]]
  main = "domain.com"
  sans = ["app.domain.com", "api.domain.com"]

码头工人-compose.yml

version: '3'

services:
  reverse-proxy:
    image: traefik
    command: --api --docker
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080" # The Web UI (enabled by --api)
    networks:
      - web
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /opt/traefik/traefik.toml:/home/project/traefik.toml
      - /opt/traefik/acme.json:/home/project/acme.json
  api:
    build:
      context: ./api/
      dockerfile: Dockerfile
    volumes:
    - ~/api:/var/www/html
    networks:
      - web
    restart: always
    labels:
    - "traefik.enable=true"
    - "traefik.frontend.rule=Host:api.domain.com"
    - "traefik.docker.network=web"
  webapp:
    build:
      context: ./webapp/
      dockerfile: DockerfileNode
    volumes:
      - ~/webapp:/app
    networks:
      - web
    labels:
      - "traefik.frontend.rule=Host:app.domain.com"
      - "traefik.docker.network=web"
      - "traefik.enable=true"
    expose:
      - 8188
networks:
  web:
    external: true

我的 traefik 门户的屏幕截图 (注意:只有 http 入口点,没有 https)

traefik 门户显示没有 https 入口点

码头工人ps

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                                              NAMES
d956a9d25ace        webapp       "/usr/bin/kafka-sock…"   18 minutes ago      Up 16 minutes       8188/tcp                                                           webapp_1
e46693c8ca3e        api          "docker-php-entrypoi…"   21 minutes ago      Up 16 minutes       80/tcp                                                             api_1
321c5efc720b        traefik      "/traefik --api --do…"   2 hours ago         Up 16 minutes       0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:8080->8080/tcp   reverse-proxy_1

标签: dockerdocker-composelets-encrypttraefik

解决方案


推荐阅读