User session log shows local IP in Cloud

I’m testing the log of users in a server in the cloud, but I do not understand why if I’m logging in remotely it always shows me the start address, it should not be the IP of the internet provider or in its absence to the assigned to the PC?

Hello Nelson,

Probably you missed X-Real-IP, X-Forwarded-For lines in your nginx proxy config (I assume it serves your application). Here an example.

Best regards,

Ivan It’s right. I will review the documentation sent and tell you.
thx for you help

@nelsonf, please take a look into Tomcat configuration:

First add Valve to Tomcat configuration conf/server.xml and restart Tomcat:

        <Valve className="org.apache.catalina.valves.RemoteIpValve"
               internalProxies="127\.0\.0\.1"  />

This is required to dispatch Nginx headers by Tomcat without modifying web application.

Also you may need to apply proxy_cookie_path to your configuration.

In example below the request comes to Nginx server, then it is redirected to Tomcat web application running on the same server:

server {
    listen 80;
    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $host;
        proxy_set_header X-Forwarded-Server $host;
        #proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout     3600;
        proxy_connect_timeout  240;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        client_max_body_size 5m;
        proxy_cookie_path /app/ /;
        proxy_set_header Cookie $http_cookie;

1 Like