Код: Выделить всё
# see https://symfony.com/doc/current/reference/configuration/framework.html
framework:
trusted_proxies: '%env(string:APP_TRUSTED_PROXIES)%'
trusted_headers: '%env(csv:APP_TRUSTED_HEADERS)%'
< /code>
Поскольку файлы .env не читаются в моей настройке в контейнер, я устанавливаю app_trusted_headers через Docker Compose в виде запятой.docker compose exec php php bin/console debug:container --env-vars | grep APP_
< /code>
Я получаю: < /p>
In BaseNode.php line 496:
Invalid type for path "framework.trusted_headers.0". Expected one of "bool"
, "int", "float", "string", but got "array".
< /code>
trusted_headersКак воспроизвести? class = "Lang-Bash PrettyPrint-Override">
Код: Выделить всё
git clone https://github.com/dunglas/symfony-docker
cd symfony-docker
docker compose build --pull --no-cache
docker compose up --wait
< /code>
Then edit the config/packages/framework.yaml and add:
framework:
trusted_headers: '%env(csv:APP_TRUSTED_HEADERS)%'
< /code>
In compose.yaml, define the env var. I tried the following (each variant tested separately):
service:
php:
environment:
APP_TRUSTED_HEADERS: forwarded,x-forward-port # does NOT WORK
APP_TRUSTED_HEADERS: forwarded # does NOT WORK
APP_TRUSTED_HEADERS: "forwarded" # does NOT WORK
APP_TRUSTED_HEADERS: "'forwarded'" # does NOT WORK
APP_TRUSTED_HEADERS: "${APP_TRUSTED_HEADERS}" # with the host env set
< /code>
All variants result in the same error.
I read "Environment variable processors", this post about "Environment variables in a dockerized Symfony" and How to Configure Symfony to Work behind a Load Balancer or a Reverse Proxy
What am I doing wrong, and how should APP_TRUSTED_HEADERS be passed so that %env(csv:...)%Подробнее здесь: https://stackoverflow.com/questions/797 ... sh-with-go
Мобильная версия