プロキシサーバー経由のアクセス元IPアドレスを取得するのにハマったのでメモ。
結論、SymfonyRequest#setTrustedProxies(array) を呼べばOK。
$request::setTrustedProxies([Request::ip()]);
この後に
Request::ip()
を呼ぶとアクセス元のIPアドレスを取得できます。
LaravelのRequestがSymfonyRequesを継承してて、getClientIp()メソッド(Request::ip()の参照先)コメントにちゃんと書いてありました。
* This method can read the client IP address from the "X-Forwarded-For" header * when trusted proxies were set via "setTrustedProxies()". The "X-Forwarded-For" * header value is a comma+space separated list of IP addresses, the left-most * being the original client, and each successive proxy that passed the request * adding the IP address where it received the request from.
しっかり読め、ということですねw