How can I get the IP of an HTTP request in a Laravel Vapor application?

Solution 1:

There is x-vapor-source-ip header in latest Vapor core package (vapor-core:v2.2.1) which exposes Lambda's sourceIp property in order to get the client's real ip safely.

You can retrieve the ip:

Request::header('x-vapor-source-ip')

Solution 2:

"we do not have a load balancer set up" Yes, you do. The API Gateway is, fundamentally, a proxy of exactly the sort that the trusted proxy configuration is intended for.

Set 'proxies' => '*' in your config/trustedproxy.php file and you should start seeing the right IP addresses.