traefik - https://www 上的 Traefik 404
问题描述
我正在使用这个配置:
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 不起作用。
我尝试了很多建议,正则表达式中间件没有成功。这只是完全相同的结果。
解决方案
我需要在 Host() 中的站点名称周围添加反引号:
- "traefik.http.routers.mysite.rule=Host(`mysite.com`, `www.mysite.com`)"
- "traefik.http.routers.mysite-secured.rule=Host(`mysite.com`, `www.mysite.com`)"
另外,我的部署是错误的。有时我会临时上传文件,然后手动运行一个用旧版本覆盖的 post-receive 挂钩。
推荐阅读
- typescript - AssertionError:被测对象必须是数组、映射、对象、集合、字符串或弱集,但对象已给定
- python - Python - Gherkin Step 转换
- python - 使用请求将字符串作为 multipart/form-data 发布
- java - 当通过 post 命令将对象发送到 spring WebApp 时,对象字段为空
- node.js - node-schedule 的对象处理和日历架构
- python - 如何在 Windows 8 中为 python 3.7 下载 matplotlib?
- docker - -bash:码头工人:找不到命令
- javascript - Console.log 并等待
- qt - 如何在 QToolButton 上显示虚线焦点矩形
- asp.net - ADFS 单点登录不适用于会话状态模式“UserUri”