【问题标题】:Symfony in nginx https + varnish + apache http = redirect loop ornginx https + varnish + apache http = 重定向循环中的 Symfony 或
【发布时间】:2019-02-02 20:33:19
【问题描述】:

我有配置 nginx https + varnish + apache http = 重定向循环中的 Symfony

我提出了路由方案以获取链接 https : ['https'] 但是为什么要重定向循环? 看起来 symfony 不仅使用 https 创建链接,而且在获取 http 时返回重定向 - 我需要 http 页面在清漆中缓存,但链接 https。

更新 1 当我没有在路由中放置模式并通过 https 运行页面时,几乎所有工作都正常 - 没有

1 fos 路由它创建绝对 http 链接

2 liip 想象同样的情况

【问题讨论】:

  • 这个问题需要添加所有必要的配置。

标签: symfony varnish liipimaginebundle fosjsroutingbundle


【解决方案1】:

如果您在访问页面时尽管使用 https,但仍重定向到 https,则原始协议不会被转发到处理响应的后端。

有一个标头X-Forwarded-Proto 在通过任何代理之前应设置为包含原始协议。 Symfony 应该尊重此标头并接受请求是安全的而不是重定向(如果适当,还可以将所有链接设置为 https:// url)

您需要配置 Apache(我假设它正在终止 https 连接并拥有证书)以设置此标头以匹配原始请求协议。

看起来您可能需要信任代理,Symfony 才会遵守标头 Symfony Docs for proxies

// public/index.php

// ...
$request = Request::createFromGlobals();

// tell Symfony about your reverse proxy
Request::setTrustedProxies(
    // the IP address (or range) of your proxy
    ['192.0.0.1', '10.0.0.0/8'],

    // trust *all* "X-Forwarded-*" headers
    Request::HEADER_X_FORWARDED_ALL
);

【讨论】:

    猜你喜欢
    • 2015-03-11
    • 1970-01-01
    • 1970-01-01
    • 2019-08-13
    • 2016-03-18
    • 2015-12-09
    • 1970-01-01
    • 2015-01-08
    • 2019-06-16
    相关资源
    最近更新 更多