我有两层应用程序结构(Nginx(proxy)+ nodejs(app)。我需要在我的应用程序中获取我的客户端IP(谁访问我的网站)的NodeJS)。现在,我的客户端IP,它越来越记录在我的Nginx的日志文件(通过启用下面的conf在nodejs应用程序中了解我的客户端ip
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
现在我得到我的应用程序服务器Nginx的服务器IP,但我不希望得到我的Nginx服务器的IP,而不是我需要让我的原始客户端IP在我的应用程序
这是应用程序代码中,我们使用的是获取客户端IP中 应用服务器。
request.headers['x-forwarded-for'] || request.info.remoteAddress
其中; Nodejs--> Happijs框架
我认为这是你正在寻找的答案: HTTPS: //stackoverflow.com/questions/30943112/get-ip-user-with-nginx-and-node#30943228 – Red8