How to obtain external IP Address of users?

I need to register the external IP Address of users that are logged in into a cuba application. So, I want to ask you if there is any method in the platform giving this information - Please note that our application is running behind a reverse proxy and I am wondering how I could possibly obtain from request’s X-Forwarded-For header this info.

Thank you

Hi @papageor, since you are using a reverse proxy, it is up to him to inform you. If you use nginx this can help you.


Nelson F.


To support proxy server, you have to do three things:

  1. Tune your proxy server to pass X-Forwarded-For header.

  2. Configure your application server.
    For tomcat - configure RemoteIpValve in server.xml:
    Proxy Configuration for Tomcat - CUBA Platform. Developer’s Manual
    For Jetty or UberJar - confgure ForwardedRequestCustomizer in jetty-env.xml :
    Proxy Configuration for Uber JAR - CUBA Platform. Developer’s Manual

  3. Then in the CUBA application you can just call javax.servlet.ServletRequest#getRemoteAddr to get real IP address.

I think you can use this method: com.haulmont.cuba.web.sys.RequestContext#get
to obtain current http request object in the web module.

Also note that CUBA already stored IP addresses of logged in users and shows them in Administration → User Sessions screen.
You can obtain this information programmatically by using service method.

Hi Alex,
Thank you very much for your assistance. This actually solved my problem!

George Papageorgiou