3

I have been using PHP Ratchet with Stunnel for SSL. It's working well. But the problem is, I can't get users real IP address.

I already tried these

$conn->remoteAddress

and with this I am getting 127.0.0.1 (local address)

$conn->WebSocket->request->getHeader('X-Forwarded-For');

and with this I am getting nothing.

Any help!

h_h
  • 1,201
  • 4
  • 28
  • 47

2 Answers2

1

Or sometimes it's $conn->httpRequest->getHeaders()['X-Forwarded-For'][0].

John Alexander
  • 822
  • 1
  • 12
  • 21
0

This is really old, but I ran into it just now.

You're looking for $conn->WebSocket->request->getHeader('x-forwarded-for) or $conn->WebSocket->request->getHeader('x-real-ip').

See $conn->WebSocket->request->getHeaders() for the entire list.

Rian
  • 286
  • 2
  • 11