Open iascchen opened 9 years ago
Sorry for the delayed response. Just getting back from a weekend trip. From what I've seen, using the X-Forwarded-For
header is the only way to get the client IP when the server is behind a proxy. You can check out these StackOverflow answers here and here for more information on that.
What I will gladly do is add the client IP address into the endpoint context at this.clientIp
, similar to Express. I'll convert this issue to a feature request, since it is the intended behavior at the moment. If someone wants to do it, I'll definitely accept a pull request on this. It's a pretty straightforward update. To make my life easier, I'm just going to add this into the 0.7.0 release (or shortly after), so I don't have to put in any extra effort to rebase it. Any PRs should be made on the 0.7.0
branch.
I want to get the client ip address on restivus restful api, but I found when i use
this.request.connection.remoteAddress
only return 127.0.0.1. Is it a bug?My sample code as follow:
But I found
var deviceIp = this.request.headers["x-forwarded-for"];
will return right ip address