peer(Req :: cowboy_req:req()) -> Info Info :: {inet:ip_address(), inet:port_number()}
cowboy_req:peer - Peer address and port
peer(Req :: cowboy_req:req()) -> Info Info :: {inet:ip_address(), inet:port_number()}
Return the peer's IP address and port number.
The peer information can also be obtained using pattern matching:
#{peer := {IP, Port}} = Req.
The Req object.
The peer's IP address and port number.
The peer is not necessarily the client's IP address and port. It is the IP address of the endpoint connecting directly to the server, which may be a gateway or a proxy.
The forwarded header can be used to get better information about the different endpoints from the client to the server. Note however that it is only informative; there is no reliable way of determining the source of an HTTP request.
{IP, Port} = cowboy_req:peer(Req).