Magento 2:traefik反向代理背后的重定向过多

时间:2018-07-29 15:00:59

标签: apache docker reverse-proxy magento2 traefik

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

  1. 特拉菲克:192.168.1.30
  2. Magento:192.168.1.224

Traffic进入端口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正常显示。

我在这里想念什么?

4 个答案:

答案 0 :(得分:0)

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

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

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

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

答案 1 :(得分:0)

  • 下面的代码发出命令解决了这种情况 OR
  • 在Traefik上启用ACME并将Cloudflare上的SSL模式切换为Full(如果已启用)
[entryPoints.http.redirect]
    entryPoint = "https"

答案 2 :(得分:0)

实际上,该配置完全有效,但是Cloudflare的crypto / SSL设置被设置为Flexible而不是Full;造成循环。

答案 3 :(得分:0)

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

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

在我们的kubernetes入口清单中并对其进行了修复。