I had the same problem. I used the "REMOTE_ADDR" method on my website and it was showing up my cloudflare ip address. I wanted to echo the users ip, so this answer helped me out a ton.
I'm going to use this with Symfony's HTTP Foundation like so:
use Symfony\Component\HttpFoundation\Request; $request ??= Request::createFromGlobals(); $ip = $request->server->get( 'HTTP_CLIENT_IP', $request->server->get( 'HTTP_CF_CONNECTING_IP', $request->server->get( 'HTTP_X_FORWARDED', $request->server->get( 'HTTP_X_FORWARDED_FOR', $request->server->get( 'HTTP_FORWARDED', $request->server->get( 'HTTP_FORWARDED_FOR', $request->server->get('REMOTE_ADDR') ) ) ) ) ) );
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I had the same problem. I used the "REMOTE_ADDR" method on my website and it was showing up my cloudflare ip address. I wanted to echo the users ip, so this answer helped me out a ton.
I'm going to use this with Symfony's HTTP Foundation like so: