Getting IP address and location of my own server instead of visiting user's

Here's the Nginx Conf which works for me, placed at the path /etc/nginx/conf.d/example.com.conf.

server {
    listen 80;
    listen [::]:80;
    server_name example.com;

    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    location / {
        proxy_pass "http://localhost:1234/";
    }
}

No other Nginx Conf required, as of my previous implementation i was having another conf file at the /etc/nginx/sites-available/default directory which was conflicting as a Duplicate Server Name. Lastly, i would like to add that use Nginx Testing command before resetting the changes. Which was a huge help. Command: nginx -t.

And in Node.js, this is the most appropriate way to access Client's IP Address.

var getClientAddress = (req.headers['x-forwarded-for'] || '').split(',')[0] 
                       || req.connection.remoteAddress;
console.log(getClientAddress);

Cheers ;-)