How to find client ip for https request (e.g. secure connection) in Rails 2.3.8

I am making an application in which I need to find the IP address of a client. I used request.remote_ip to get the IP address of the client, and it got the public IP address of the client for the HTTP request. When this request is https request.remote_ip chose a different ip as 10.114.237.132 (I think it is a private ip), except for the public ip address. I also tried request.env ['REMOTE_ADDR'] My question is how to find the remote client ip for the https request.

+4
source share
1 answer

If this is the laod balancer IP address, try to find out if it can provide you with an HTTP header to get the client IP address. If you can configure it or already check it, you can check the HTTP headers using this method of the Request.headers () method .

The title you should be looking for is X-Forwarded-For .

0
source

Source: https://habr.com/ru/post/1481166/


All Articles