我有兩層應用程序結構(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