我有 NGINX 作为反向代理运行,它将所有 http 和 https 流量转发到我的 node.js 应用程序,它侦听 localhost:port
但是,我遇到的问题是 node.js 应用程序将所有传入请求视为来自 ::ffff:127.0.0.1
如何更改 NGINX 配置,以便将真实 IP 传递并转发到 node.js 应用程序?
server {
listen 80;
listen [::]:80;
listen 443;
listen [::]:443;
root /var/www/example.com/html;
index index.html index.htm;
server_name example.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://localhost:myport;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
# Requests for socket.io are passed on to Node on port x
location ~* \.io {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header …Run Code Online (Sandbox Code Playgroud) 将类似WhatsApp的视频聊天和文本聊天实现到自己的应用中的最佳方法是什么?可靠性,易于集成和归档以及最终定价。