代码之家  ›  专栏  ›  技术社区  ›  Developer

nginx中的Symfony https+varnish+apache http=重定向循环或

  •  -1
  • Developer  · 技术社区  · 6 年前

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

    我放置路由方案以获取链接https:['https'] 它看起来symfony不仅创建链接与https,但返回重定向如果得到http-我需要http页面缓存在清漆,但链接https。

    更新1 当我在路由中不使用任何模式并在https上运行页面时,几乎所有的东西都可以工作-没有

    1它创建绝对的http链接

    想象一下同样的情况

    1 回复  |  直到 6 年前
        1
  •  1
  •   MattWhiteley    6 年前

    如果您在访问页面时得到了一个重定向到https的消息(尽管使用了https),那么原始协议不会被转发到处理响应的后端。

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

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

    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
    );
    
    推荐文章