diff --git a/src/docs/user/configuration/configuring_preamble.diviner b/src/docs/user/configuration/configuring_preamble.diviner index a8710598bf..bb76600d3b 100644 --- a/src/docs/user/configuration/configuring_preamble.diviner +++ b/src/docs/user/configuration/configuring_preamble.diviner @@ -4,7 +4,8 @@ Adjust environmental settings (SSL, remote IP, rate limiting) using a preamble script. -= Overview = +Overview +======== If Phabricator is deployed in an environment where HTTP headers behave oddly (usually, because it is behind a load balancer), it may not be able to detect @@ -37,27 +38,52 @@ If present, this script will be executed at the very beginning of each web request, allowing you to adjust the environment. For common adjustments and examples, see the next sections. -= Adjusting Client IPs = +Adjusting Client IPs +==================== If your install is behind a load balancer, Phabricator may incorrectly detect -all requests as originating from the load balancer, rather than from the correct -client IPs. If this is the case and some other header (like `X-Forwarded-For`) -is known to be trustworthy, you can overwrite the `REMOTE_ADDR` setting so -Phabricator can figure out the client IP correctly: +all requests as originating from the load balancer, rather than from the +correct client IPs. + +If this is the case and some other header (like `X-Forwarded-For`) is known to +be trustworthy, you can read the header and overwrite the `REMOTE_ADDR` value +so Phabricator can figure out the client IP correctly. + +You should do this //only// if the `X-Forwarded-For` header is known to be +trustworthy. In particular, if users can make requests to the web server +directly, they can provide an arbitrary `X-Forwarded-For` header, and thereby +spoof an arbitrary client IP. + +The `X-Forwarded-For` header may also contain a list of addresses if a request +has been forwarded through multiple loadbalancers. Using a snippet like this +will usually handle most situations correctly: ``` name=Overwrite REMOTE_ADDR with X-Forwarded-For