Skip to content

Commit 4dcf6aa

Browse files
docs: add trusted proxies section (#2276)
Fix #1219
1 parent 47e0c38 commit 4dcf6aa

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/production.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,29 @@ Go to `https://your-domain-name.example.com` and enjoy!
137137
>
138138
> Docker can have a cache layer, make sure you have the right build for each deployment or rebuild your project with `--no-cache` option to avoid cache issue.
139139

140+
## Running Behind a Reverse Proxy
141+
142+
If FrankenPHP is running behind a reverse proxy or a load balancer (e.g., Nginx, AWS ELB, Google Cloud LB),
143+
you must configure the [`trusted_proxies` global option](https://caddyserver.com/docs/caddyfile/options#trusted-proxies) in your Caddyfile
144+
so that Caddy trusts incoming `X-Forwarded-*` headers:
145+
146+
```caddyfile
147+
{
148+
servers {
149+
trusted_proxies static <your-IPs>
150+
}
151+
}
152+
```
153+
154+
Replace `<your-IPs>` with the actual IP ranges of your proxy if needed.
155+
156+
Additionally, your PHP framework must also be configured to trust the proxy.
157+
For example, set the [`TRUSTED_PROXIES` environment variable](https://symfony.com/doc/current/deployment/proxies.html) for Symfony,
158+
or the [`trustedproxies` middleware](https://laravel.com/docs/trustedproxy) for Laravel.
159+
160+
Without both configurations, headers such as `X-Forwarded-For` and `X-Forwarded-Proto` will be ignored,
161+
which can cause issues like incorrect HTTPS detection or wrong client IP addresses.
162+
140163
## Deploying on Multiple Nodes
141164

142165
If you want to deploy your app on a cluster of machines, you can use [Docker Swarm](https://docs.docker.com/engine/swarm/stack-deploy/),

0 commit comments

Comments
 (0)