P
P
P7472020-03-16 11:53:25
symfony
P747, 2020-03-16 11:53:25

Symfony 4 - {{ app.request.getSchemeAndHttpHost() }} returns http when https?

Good afternoon!

The site uses https, but app.request.getSchemeAndHttpHost() still returns http protocol, how can I configure this method to issue https?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Flying, 2020-03-16
@P747

If you look at the source code, you will see that the Request::getScheme()one that uses Request::getSchemeAndHttpHost() will return https depending on whether the request is recognized as secure or not by the method Request::isSecure().
The method itself isSecure() , as can be seen from the code, returns truein two cases:

  1. Either this is an HTTPS request and there is a corresponding header
  2. Either this is a request from a trusted proxy server and the server transmits information that the original request is safe

Thus, I would assume that you are using the nginx + php-fpm scheme and either nginx is not configured correctly and does not pass the necessary data, or nginx is not listed as a trusted proxy.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question