【问题标题】:Traefik 404 on https://wwwhttps://www 上的 Traefik 404
【发布时间】:2021-09-24 23:28:31
【问题描述】:

我正在使用这个配置:

version: "3.3"
services:
  traefik:
    command:
      # Get Docker as the provider
      - "--providers.docker=true"
      # Avoid that all containers are exposed
      - "--providers.docker.exposedbydefault=false"
      # Settle the ports for the entry points
      - "--entrypoints.web.address=:80"
      - "--entrypoints.web-secure.address=:443"
      # Settle the autentification method to http challenge
      - "--certificatesresolvers.myhttpchallenge.acme.httpchallenge=true"
      - "--certificatesresolvers.myhttpchallenge.acme.httpchallenge.entrypoint=web"
      # Uncomment this to get a fake certificate when testing
      #- "--certificatesresolvers.myhttpchallenge.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory"
      # Settle letsencrypt as the certificate provider
      - "--certificatesresolvers.myhttpchallenge.acme.email=___________________
      - "--certificatesresolvers.myhttpchallenge.acme.storage=/letsencrypt/acme.json"
  mysite:
    labels:
      # The labels are usefull for Traefik only
      - "traefik.enable=true"
      - "traefik.docker.network=traefik"
      # Get the routes from http
      - "traefik.http.routers.mysite.rule=Host(mysite.com, www.mysite.com)"
      - "traefik.http.routers.mysite.entrypoints=web"
      # Redirect these routes to https
      - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
      - "traefik.http.routers.mysite.middlewares=redirect-to-https@docker"
      # Get the routes from https
      - "traefik.http.routers.mysite-secured.rule=Host(mysite.com, www.mysite.com)"
      - "traefik.http.routers.mysite-secured.entrypoints=web-secure"
      # Apply autentificiation with http challenge
      - "traefik.http.routers.mysite-secured.tls=true"
      - "traefik.http.routers.mysite-secured.tls.certresolver=myhttpchallenge"

除 https://www 外,一切正常。我收到一个 SSL 错误,然后当我仍然单击继续时,我从 traefik 收到一个错误,找不到 404 页面。 http://、https://、http://www 都可以,重定向到 https://。但是 https://www 不行。

我尝试了很多建议,正则表达式中间件都没有成功。这只是完全相同的结果。

【问题讨论】:

  • 显然该路由不适用于www。您是否尝试过在 DEBUG 模式下运行或访问 treafik 仪表板?你在哪里运行网站?

标签: traefik


【解决方案1】:

我需要在 Host() 中的站点名称周围添加反引号:

- "traefik.http.routers.mysite.rule=Host(`mysite.com`, `www.mysite.com`)"
- "traefik.http.routers.mysite-secured.rule=Host(`mysite.com`, `www.mysite.com`)"

另外,我的部署是错误的。有时我会临时上传文件,然后手动运行一个接收后挂钩,该挂钩会覆盖旧版本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-13
    • 2023-01-04
    • 2015-03-07
    • 1970-01-01
    相关资源
    最近更新 更多