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.
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.
To support proxy server, you have to do three things:
Tune your proxy server to pass X-Forwarded-For header.
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
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 com.haulmont.cuba.security.app.UserSessionService#getUserSessionInfo service method.
Thank you very much for your assistance. This actually solved my problem!