Skip to content

Commit a9f9885

Browse files
authored
Add FORWARDED_FOR_HEADERS to the reverse-proxy config (#2272)
* Add FORWARDED_FOR_HEADERS to the reverse-proxy config Signed-off-by: Dominic Giebert <dominic.giebert@suse.com> * Add FORWARDED_FOR_HEADERS to documentation Signed-off-by: Dominic Giebert <dominic.giebert@suse.com> --------- Signed-off-by: Dominic Giebert <dominic.giebert@suse.com>
1 parent 8c777a4 commit a9f9885

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

.config/reverse-proxy.config.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,8 @@
2828
if ($trustedProxies) {
2929
$CONFIG['trusted_proxies'] = array_filter(array_map('trim', explode(' ', $trustedProxies)));
3030
}
31+
32+
$forwardedForHeaders = getenv('FORWARDED_FOR_HEADERS');
33+
if ($forwardedForHeaders) {
34+
$CONFIG['forwarded_for_headers'] = array_filter(array_map('trim', explode(' ', $forwardedForHeaders)));
35+
}

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ To use the hooks triggered by the `entrypoint` script, either
261261
```
262262

263263

264-
## Using the apache image behind a reverse proxy and auto configure server host and protocol
264+
## Using the image behind a reverse proxy and auto configure server host and protocol
265265

266266
The apache image will replace the remote addr (IP address visible to Nextcloud) with the IP address from `X-Real-IP` if the request is coming from a proxy in `10.0.0.0/8`, `172.16.0.0/12` or `192.168.0.0/16` by default. If you want Nextcloud to pick up the server host (`HTTP_X_FORWARDED_HOST`), protocol (`HTTP_X_FORWARDED_PROTO`) and client IP (`HTTP_X_FORWARDED_FOR`) from a trusted proxy, then disable rewrite IP and add the reverse proxy's IP address to `TRUSTED_PROXIES`.
267267

@@ -276,6 +276,7 @@ If the `TRUSTED_PROXIES` approach does not work for you, try using fixed values
276276
- `OVERWRITECLIURL` (empty by default): Set the cli url of the proxy (e.g. https://mydnsname.example.com)
277277
- `OVERWRITEWEBROOT` (empty by default): Set the absolute path of the proxy.
278278
- `OVERWRITECONDADDR` (empty by default): Regex to overwrite the values dependent on the remote address.
279+
- `FORWARDED_FOR_HEADERS` (empty by default): HTTP headers with the original client IP address
279280

280281
Check the [Nexcloud documentation](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/reverse_proxy_configuration.html) for more details.
281282

0 commit comments

Comments
 (0)