nginx as load balancer: Can it return to the client which app server the request was sent to?

Solution 1:

I guess, you're looking for $upstream_addr variable.

It will contain one of 192.168.104.xx:1124.

upstream appserver {
   least_conn;
   server 192.168.104.53:1124;
   server 192.168.104.51:1124;
   server 192.168.104.59:1124;
}

server {

   listen 80;
   server_name  localhost;

   location / {
       proxy_pass http://appserver;
       add_header "X-Upstream-Addr" $upstream_addr;
   }

}