Skip to content

Commit d9c4086

Browse files
author
tchapi
committed
Add SYMFONY_TRUSTED_PROXIES in example Docker files and Readme
1 parent ba7bef5 commit d9c4086

File tree

6 files changed

+13
-0
lines changed

6 files changed

+13
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,13 @@ APP_TIMEZONE=Australia/Lord_Howe
206206
> ```
207207
> in your environment file if you wish to use the **actual default timezone of the server**, and not enforcing it.
208208
209+
**j. Trusting forwarded headers**
210+
211+
If you're behind one or several proxies, the TLS termination might be upstream and the application might not be aware of the HTTPS context. In order for urls to be generated with the correct scheme, you should indicate that you trust the chain of proxies until the TLS termination one. You can use the Symfony mechanism for that (see [documentation](https://symfony.com/doc/7.2/deployment/proxies.html) for possible values):
212+
213+
```shell
214+
SYMFONY_TRUSTED_PROXIES=127.0.0.1,REMOTE_ADDR
215+
```
209216
210217
#### Overriding the dotenv (`.env`) path
211218

docker/.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,5 @@ MAIL_PORT=587
5454
MAIL_USERNAME=userdav
5555
MAIL_PASSWORD=test
5656

57+
# Trust the proxy so that HTTPs context is forwarded
58+
SYMFONY_TRUSTED_PROXIES=REMOTE_ADDR

docker/docker-compose-postgresql.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ services:
4040
- DATABASE_DRIVER=postgresql
4141
- DATABASE_URL=postgresql://${DB_USER}:${DB_PASSWORD}@postgresql:5432/${DB_DATABASE}?serverVersion=15&charset=UTF-8
4242
- MAILER_DSN=smtp://${MAIL_USERNAME}:${MAIL_PASSWORD}@${MAIL_HOST}:${MAIL_PORT}
43+
- SYMFONY_TRUSTED_PROXIES=REMOTE_ADDR
4344
depends_on:
4445
- postgresql
4546
volumes:

docker/docker-compose-sqlite.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ services:
3030
- DATABASE_DRIVER=sqlite
3131
- DATABASE_URL=sqlite:////data/davis-database.db # ⚠️ 4 slashes for an absolute path ⚠️ + no quotes (so Symfony can resolve it)
3232
- MAILER_DSN=smtp://${MAIL_USERNAME}:${MAIL_PASSWORD}@${MAIL_HOST}:${MAIL_PORT}
33+
- SYMFONY_TRUSTED_PROXIES=REMOTE_ADDR
3334
volumes:
3435
- davis_www:/var/www/davis
3536
- davis_data:/data

docker/docker-compose-standalone.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ services:
2727
- DATABASE_DRIVER=mysql
2828
- DATABASE_URL=mysql://${DB_USER}:${DB_PASSWORD}@mysql:3306/${DB_DATABASE}?serverVersion=mariadb-10.6.10&charset=utf8mb4
2929
- MAILER_DSN=smtp://${MAIL_USERNAME}:${MAIL_PASSWORD}@${MAIL_HOST}:${MAIL_PORT}
30+
- SYMFONY_TRUSTED_PROXIES=REMOTE_ADDR
3031
depends_on:
3132
- mysql
3233
ports:

docker/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ services:
4343
- DATABASE_DRIVER=mysql
4444
- DATABASE_URL=mysql://${DB_USER}:${DB_PASSWORD}@mysql:3306/${DB_DATABASE}?serverVersion=mariadb-10.6.10&charset=utf8mb4
4545
- MAILER_DSN=smtp://${MAIL_USERNAME}:${MAIL_PASSWORD}@${MAIL_HOST}:${MAIL_PORT}
46+
- SYMFONY_TRUSTED_PROXIES=REMOTE_ADDR
4647
depends_on:
4748
- mysql
4849
volumes:

0 commit comments

Comments
 (0)