Determine client IP-address?

88 views
Skip to first unread message

mads.ha...@gmail.com

unread,
Feb 28, 2016, 9:41:08 AM2/28/16
to phoenix-talk
Hi

How can I detect the IP address of incoming requests?

Initially I thought the 'remote_ip' key on the conn map was what I was looking for, but it doesnt seem to be the ip of the client
 

dmor...@gmail.com

unread,
Mar 7, 2016, 7:31:06 AM3/7/16
to phoenix-talk, mads.ha...@gmail.com
Are you going through a proxy? You may have to look at the "forwarded" header on the request.

2016年2月28日日曜日 23時41分08秒 UTC+9 mads.ha...@gmail.com:

Alex Shneyderman

unread,
Mar 7, 2016, 11:18:42 AM3/7/16
to phoenix-talk, mads.ha...@gmail.com
It depends on how you run your server. if you accept requests through proxy (nginx for example) the remote ip will be that of your nginx proxy. You need to configure nginx to pass on the actual remote IP via some header. If you have nothing between your server and the client then conn.peer should get you the IP of the client. Also, some clients will go over a gateway, so their IP as user reports them might not be the IP as you see them on the server. 
Reply all
Reply to author
Forward
0 new messages