简体   繁体   English

在Sun Java System Web服务器中保留客户端IP地址

[英]Preserving the Client IP Address in Sun Java System Web Server

We are running Sun java System Web server 7.0 and Sun Java System App Server 9.1 (glassfish) in our environment. 我们在我们的环境中运行Sun Java System Web服务器7.0和Sun Java System App Server 9.1(glassfish)。

We need to perform some access control check in the application based on the client's IP address. 我们需要根据客户端的IP地址在应用程序中执行一些访问控制检查。 Currently the method request.getRemoteAddr() when called from the application returns the Webserver's IP address. 当前,从应用程序调用时,方法request.getRemoteAddr()返回Web服务器的IP地址。 The method request.getHeader("HTTP_X_FORWARDED_FOR") returns null. 方法request.getHeader(“ HTTP_X_FORWARDED_FOR”)返回null。

Looks like the web server is changing the header before forwarding to the application server. 看起来Web服务器在转发到应用程序服务器之前正在更改标头。

Is there a way to let the Sun Java webserver retain the original client IP address in the request? 有没有办法让Sun Java Web服务器在请求中保留原始客户端IP地址?

Please let me know. 请告诉我。

Thanks 谢谢

Try request.getHeader("x-forwarded-for") . 尝试request.getHeader("x-forwarded-for") I tested it for Squid. 我测试了鱿鱼。

You can see every parameters names by iterating through request.getParameterNames() . 您可以通过遍历request.getParameterNames()来查看每个参数名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM