【问题标题】:'Internal Server Error' when deploying Application with Traefik and LetsEncrypt使用 Traefik 和 LetsEncrypt 部署应用程序时出现“内部服务器错误”
【发布时间】:2020-04-16 22:11:43
【问题描述】:

我是使用 Traefik 的 SSL 证书的新手,并且在成功部署时遇到了真正的麻烦。

我有一个服务器和域,我已经部署了我的应用程序,使用 Traefik 和 Http 没有问题。我现在想部署相同的应用程序,在端口 9000 上运行,在 Traefik docs 之后使用 LetsEncrypt 部署在 Https 中。我可以使用 SSL 检查器验证证书是否已正确创建,但是,当我尝试访问该站点时,我得到了Internal Server Error。两个 docker 日志中都没有报告错误,我不知道接下来要尝试什么。

docker-compose.yml

version: '2'

services:
  traefik:
    image: traefik:v1.7
    restart: always
    ports:
      - 80:80
      - 443:443
    networks:
      - web
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /opt/traefik/traefik.toml:/traefik.toml
      - /opt/traefik/acme.json:/acme.json
    container_name: traefik

  app:
    image: myapp_image
    container_name: app
    restart: always
    networks:
      - web
    ports:
      - "9000:9000"
    labels:
      - "traefik.docker.network=web"
      - "traefik.enable=true"
      - "traefik.basic.frontend.rule=Host:myapp.com"
      - "traefik.basic.port=9000"
      - "traefik.basic.protocol=http"
      - "traefik.admin.frontend.rule=Host:myapp.com"
      - "traefik.admin.protocol=https"
      - "traefik.admin.port=9000"

networks:
  web:
    external: true

traefik.toml

debug = false

logLevel = "ERROR"
defaultEntryPoints = ["https","http"]

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

[retry]

[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "myapp.com"
watch = true
exposedByDefault = false

[acme]
email = "myemail@email.com"
storage = "acme.json"
entryPoint = "https"
onHostRule = true
[acme.httpChallenge]
entryPoint = "http"

【问题讨论】:

    标签: docker ssl https lets-encrypt traefik


    【解决方案1】:

    终于找到了一个可行的解决方案。我可能只是在使用旧信息,但使用 LetsEncrypt 在 Https 上使用 Traefik 托管应用程序的最佳参考是 here

    工作的 Yaml 示例如下。使用这个例子也将消除对 Toml 文件的需要!

    version: "3.3"
    
    services:
    
      traefik:
        image: "traefik:v2.2"
        container_name: "traefik"
        command:
          #- "--log.level=DEBUG"
          - "--api.insecure=true"
          - "--providers.docker=true"
          - "--providers.docker.exposedbydefault=false"
          - "--entrypoints.websecure.address=:443"
          - "--certificatesresolvers.myresolver.acme.tlschallenge=true"
          #- "--certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory"
          - "--certificatesresolvers.myresolver.acme.email=postmaster@example.com"
          - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
        ports:
          - "443:443"
          - "8080:8080"
        volumes:
          - "./letsencrypt:/letsencrypt"
          - "/var/run/docker.sock:/var/run/docker.sock:ro"
    
      whoami:
        image: "containous/whoami"
        container_name: "simple-service"
        labels:
          - "traefik.enable=true"
          - "traefik.http.routers.whoami.rule=Host(`whoami.example.com`)"
          - "traefik.http.routers.whoami.entrypoints=websecure"
          - "traefik.http.routers.whoami.tls.certresolver=myresolver"
    

    【讨论】:

      猜你喜欢
      • 2022-12-09
      • 2014-07-08
      • 1970-01-01
      • 2021-10-07
      • 2021-10-14
      • 1970-01-01
      • 1970-01-01
      • 2019-11-27
      • 2017-11-05
      相关资源
      最近更新 更多