If it gives you the wrong one, you can use $request->ips() to get all ip's collected, and you can check if the correct one is further down the list. Perhaps you need $request->ips()[1]
@russelmhardy If your production server is running behind a load balancer or proxy then yes, you’ll get the IP address of that load balancer/proxy because that is what’s connecting to your app.
You’ll need to update your TrustProxies middleware to read things like the scheme and end user’s IP address. The “nuclear” version is:
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;
class TrustProxies extends Middleware
{
protected $proxies = '*';
protected $headers = Request::HEADER_X_FORWARDED_AWS_ELB;
}
That will trust connections from all addresses. If the load balancer/proxy you’re using has a static IP address then it’d be better to specify that instead.