Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring WebAuthenticationDetails getRemoteAddress()未返回客户端的实际ip地址_Spring_Spring Security - Fatal编程技术网

Spring WebAuthenticationDetails getRemoteAddress()未返回客户端的实际ip地址

Spring WebAuthenticationDetails getRemoteAddress()未返回客户端的实际ip地址,spring,spring-security,Spring,Spring Security,我正在应用程序中使用WebAuthenticationDetails。即使我从不同的客户端计算机登录应用程序,WebAuthenticationDetails的getRemoteAddress()方法也会返回相同的IP地址。这可能是由于代理服务器造成的。有人能帮我解决此问题吗?如果您的应用程序正在使用a(例如nginx、Apache等)系统然后,您将始终在WebAuthenticationDetails对象中看到反向代理计算机的IP。要解决此问题,可以配置反向代理,使其使用HTTP头将客户端的I

我正在应用程序中使用WebAuthenticationDetails。即使我从不同的客户端计算机登录应用程序,WebAuthenticationDetails的getRemoteAddress()方法也会返回相同的IP地址。这可能是由于代理服务器造成的。有人能帮我解决此问题吗?

如果您的应用程序正在使用a(例如nginx、Apache等)系统然后,您将始终在WebAuthenticationDetails对象中看到反向代理计算机的IP。要解决此问题,可以配置反向代理,使其使用HTTP头将客户端的IP地址发送到应用程序服务器。然后在您的webapp中,从该标头获取clinet的IP。

还有其他方法吗?是:1)关闭反向代理或2)尝试配置Spring安全性,以便在初始化WebAuthenticationDetails时使用该标头(因此您将继续使用此对象)。你到底为什么想要其他选项?我不知道如何在web.xml中配置spring安全性。你能给我提供任何链接来帮助我配置web.xml吗?这很简单。查阅官方文件。