Closed aqiu9 closed 4 months ago
这是反向代理上的问题
Nginx请参考
location ^~ / {
proxy_pass http://127.0.0.1:5700;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
add_header X-Cache $upstream_cache_status;
add_header Cache-Control no-cache;
}
如果你是使用 1Panel直接配置反向代理即可,默认带有此配置
谢谢,经过你的提醒我看了下qinglong的代码,调用的是request-ip的getClientIp,该函数会取头部的真实IP。
奇怪,我图里抓到的包显示包头的X-Real-IP是正确的,但是日志里却是内网IP。。可能哪里出现了问题,我得再找找
Clear and concise description of the problem
有反向代理的时候,登录日志只显示内网登录:
Suggested solution
例如:规定一个可识别的头,在代理服务里用户加上该头便可识别正确的登录IP。
Alternative
No response
Additional context
No response
Validations