我正在 docker-compose 中使用
network_mode: host
运行 traefik 以获得准确的remote_ip。我的 docker 主机端口 80 和 443 被占用,因此 traefik 使用 5080 和 5443 Web 和 Websecure 入口点。我已将 5080/5443 转发到我的路由器 80/443,因此 my.domain.me
路由到 traefik。 https://my.domain.me
工作正常,但是http://my.domain.me
重定向到端口5443。如何配置traefik重定向到端口443?
version: '3.3'
services:
traefik:
image: traefik:v2.4
# use host network for accurate remote_ip
network_mode: host
command: # CLI arguments
- --providers.docker=true
# ports 80 and 443 are used by another process.
- --entryPoints.web.address=:5080
- --entryPoints.websecure.address=:5443
- --entrypoints.web.http.redirections.entrypoint.to=websecure
- --entrypoints.web.http.redirections.entrypoint.scheme=https
我最近遇到了这个问题,这是我找到的解决方案:
文档说
redirections.entrypoint.to
可以是另一个入口点OR显式端口。基本上,将其设置为命名入口点只是说“请重定向到此入口点的端口”。
因此在您的示例中,CLI 参数应该是:
--entrypoints.web.http.redirections.entrypoint.to=:443