[英]How to get client real ip on Nginx server
当我尝试获取客户端 ip 时遇到问题,它为每个客户端提供相同的 ip 地址。 我将这些行添加到我的 nginx.conf 文件中:
set_real_ip_from 127.0.0.1;
set_real_ip_from 0:0:0:0:0:0:0:1;
set_real_ip_from 192.168.56.1;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
#proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
(I am not sure to add this part.)
但它仍然无法正常工作。 有没有人有什么建议?
如果要在 Spring Boot 上获取客户端 IP 地址,需要将server.forward-headers-strategy
设置为native
。
application.properties
:
server.forward-headers-strategy=native
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.