anyproxy
anyproxy copied to clipboard
hi, 请问我如何获取client IP?
AnyProxy 4.x 在rule中,如何能够获取到通过anyproxy代理的client ip? 谢谢。
在AnyProxy的接口 beforeSendRequest 中,通过_req将request对象返回, 这是原始的http request 对象,可以通过它来获取client ip, 似乎是 request.connection.remoteAddress?
我测试是req._req.socket.remoteAddress和req._req.connection.remoteAddress都可以呢
请问如果是https代理。拿到的都是127.0.0.1怎么办?@codingfishman
原来和 #339 一样啊
requestDetail._req.socket.remoteAddress
@KyleQiao1992 我看到你提的issue也是https拿到127.0.0.1。我也碰到这个问题,请问你解决了吗。
@huhuang03 没有
请问这个问题解决了嘛?
This problem is not solved. https requests show the ip as ::ffff:127.0.0.1
a normal node https request will show the real remote address
this problem kill my so many time... there is a funciton called 'beforeDealHttpsRequest(req)' you can get currentip with req._req.connection.remoteAddress. and more, this function must return true
for function beforeSendRequest(req).using the "req._req.connection.remoteAddress" gives the loopback address(127.0.01) however in function beforeDealHttpsRequest(req) the "req._req.connection.remoteAddress" gives right address
for function beforeSendRequest(req).using the "req._req.connection.remoteAddress" gives the loopback address(127.0.01) however in function beforeDealHttpsRequest(req) the "req._req.connection.remoteAddress" gives right address
U r right. And futher more, i read the source code. If the request's protocol is https , anyproxy will start a new request to the target host, which will passed to the function beforeSendRequest. That is why the remoteAddress is 127.0.0.1.