【问题标题】:Magento 2: Too many redirects behind traefik reverse-proxyMagento 2:traefik 反向代理背后的重定向太多
【发布时间】:2018-07-29 15:00:59
【问题描述】:

在我的 Web 服务器和 Docker 应用程序前面,我运行 Traefik 来处理负载平衡和反向代理。在这种特定情况下,Magento 2 运行在与 Traefik 主机相同的专用网络中的另一台主机上。

  1. Traefik:192.168.1.30
  2. Magento:192.168.1.224

流量通过端口 80/443 进入防火墙并转发到 Traefik,后者根据域名(在本例中为 exampleshop.com)转发请求。

我的 Traefik 配置如下所示:

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

[backends]
  [backends.backend-exampleshop]
    [backends.backend-exampleshop.servers.server1]
    url = "http://192.168.1.224:80
    passHostHeader = true
[frontends]
  [frontends.exampleshop]
  backend = "backend-exampleshop"
    [frontends.exampleshop.routes.hostname]
    rule = "Host:exampleshop.com"

对于常规网站,上述配置始终按预期工作(具有有效 Let's Encrypt 证书的有效 HTTPS 连接),但在 Magento 2 的情况下,它会导致:

ERR_TOO_MANY_REDIRECTS

因此,我无法同时访问我的主页和管理页面。查看数据库记录,我将我的不安全 URL 都配置为 https://exampleshop.com 以避免重定向错误。

Apache 在端口 80 上监听良好,当直接联系(通过更改我的主机文件)时,页面通过 HTTP 显示得很好。

我在这里错过了什么?

【问题讨论】:

    标签: apache docker reverse-proxy magento2 traefik


    【解决方案1】:
    • 以下代码的命令解决了这种情况
    • 在 Traefik 上启用 ACME,并将 Cloudflare 上的 SSL 模式切换为 Full(如果启用)
    [entryPoints.http.redirect]
        entryPoint = "https"
    

    【讨论】:

      【解决方案2】:

      我认为 192.168.1.224 是安装 Traefik 的 IP(本地)。

      entryPoints.http : address = ":80" == address = "0.0.0.0:80"

      • https//exampleshop.com
        • entryPoints.https(因为 https == 端口 443)
        • frontends.example1(因为rule = "Host:exampleshop.com"
        • backend-example1: server = "http://192.168.1.224:80"
        • entryPoints.http 因为:80 == http://192.168.1.224:80
        • 重定向到entryPoints.https

      尝试更改本地应用程序的端口。

      【讨论】:

      • 192.168.1.30 将是安装 Traefik 的 IP。 192.168.1.224 是 Apache/Magento 正在监听的 IP。我不是很清楚你在说什么。我已经按照您的描述定义了入口点(请参阅更新的问题),但它会导致循环。
      【解决方案3】:

      实际上,配置完全有效,但 Cloudflare 的加密/SSL 设置设置为灵活而不是完整;导致循环。

      【讨论】:

        【解决方案4】:

        我也遇到了这个问题,但我发现我必须添加这个:

        ingress.kubernetes.io/ssl-proxy-headers: "X-Forwarded-Proto: https"
        

        在我们的 kubernetes 入口清单中,它修复了它。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2020-11-11
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-06-17
          • 1970-01-01
          • 1970-01-01
          • 2019-03-14
          相关资源
          最近更新 更多