How to get a client's real ip behind upstream

Hi, I try to get real ip behind upstream, and always get 127.0.0.1, can some-one help me?

Now I use next configs:
upstream ts {
server localhost:841 weight=10 max_fails=3 fail_timeout=10s;
server 10.1.3.209:8080 backup;
}

server {
listen 80;
server_name 10.9.24.45;

    location / {  
            proxy_pass http://ts;  
            proxy_set_header Host $host;  
            proxy_set_header X-Real_IP $remote_addr;  
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  
    }  

}

server {
listen 841;
server_name localhost;

    charset utf-8;  

    access_log /var/log/nginx/access_ts.log;  
    error_log /var/log/nginx/error_ts.log;  

    client_max_body_size 16M;  

    set $www /www;  
    set $root $www/apps/ts/ROOT;  

    include /etc/nginx/sites-available/locations;  

    location / {  
            proxy_pass http://localhost:840;  
            proxy_set_header Host $host;  
            proxy_set_header X-Real_IP $remote_addr;  
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  
            include /etc/nginx/sites-available/location-config;  
    }  

}

you need to add few lines in nginx.conf file
Please check : https://rtcamp.com/tutorials/nginx/amazon-elastic-load-balancer-forward-real-ip/