Symfony2 behind ELB is redirecting to http instead of https

后端 未结 7 1351
予麋鹿
予麋鹿 2021-02-01 17:04

Issue:

  • User logs in with https://example.com/login
  • Authentication is approved
  • As configured in security.yml Symfony2 redirects u
7条回答
  •  粉色の甜心
    2021-02-01 17:55

    1. Make sure that trusted_hosts and trusted_proxies configuration properties are set appropriately.
    2. Make sure that your load balancer adds X-Forwarded-For, X-Forwarded-Host, X-Forwarded-Port and, what's most important, X-Forwarded-Proto headers to the HTTP request send to the application.

    Documentation: Trusting Proxies.


    EDIT:

    As @A23 suggested you should also check if ELB is using "standard" headers names. If not, change them using one of following:

    Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, 'X-Proxy-For');
    Request::setTrustedHeaderName(Request::HEADER_CLIENT_HOST, 'X-Proxy-Host');
    Request::setTrustedHeaderName(Request::HEADER_CLIENT_PORT, 'X-Proxy-Port');
    Request::setTrustedHeaderName(Request::HEADER_CLIENT_PROTO, 'X-Proxy-Proto');
    

提交回复
热议问题