How to get client IP address when JBoss/Tomcat is behind a load balancer such as BIG-IP or Apache httpd/mod_proxy?

Solution Verified - Updated -

Issue

  • How to get IP of clients, the request.getRemoteAddr() or request.getRemoteHost() or returns internal addresses. JBoss/Tomcat server is behind a load balancer.
  • How to validate the IP address of the clients in the application.When a load balancer is used, the IP address of the load balancer is reflected in the application. How can the IP address of the clients be retrieved? The code for getting the IP address is:

    HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
    String ipAddress = request.getRemoteAddr();
    
  • F5 load balancer is configured before jboss server. We need to capture client ip, at present it is sending in the header. What configuration should i do to capture the same ?

  • How to get the client IP address when JBoss EAP is frontend by Apache httpd server and using mod_proxy_http module?

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 4.x
    • 5.x
    • 6.x
  • Tomcat
    • 5.x
    • 6.x
  • Behind a load balancer (e.g. F5 BIG-IP) or Apache httpd/mod_proxy (not mod_proxy_ajp)

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content