I setup a load balancer with 1-click and attached 3 droplets to it. I want to know when a client made a request to the load balancer, which droplet it is connected to. I cannot find it when ssh into the droplet because the tcp connections only show the connection is from 127.0.0.1:[port].

Is there any way I can find out which droplet and which port the client is related?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi there,

What you could do is to enable PROXY Protocol for the Load balancer.

The PROXY protocol is a way to send client connection information (like origin IP addresses and port numbers) to the final backend server rather than discarding it at the load balancer.

This information can be helpful for use cases like analyzing traffic logs or changing application functionality based on geographical IP.

You can do that by following the steps here:

https://www.digitalocean.com/docs/networking/load-balancers/#proxy-protocol

And then configure your Nginx or Apache services to accept PROXY protocol headers as described here:

https://www.digitalocean.com/docs/networking/load-balancers/resources/#proxy-protocol

Hope that this helps.
Regards,
Bobby

  • Thank you! I will take a look at it and let you know if I have any question.

  • I have tried to add the following in /etc/nginx/nginx.conf:

            real_ip_header proxy_protocol;
            set_real_ip_from 10.120.0.0/24;
            listen 443 ssl proxy_protocol;
    

    Here the internal ip is based from my 3 droplets. However, after I enable proxy for load balancer, it stopped working. The default nginx version is 1.18.0. Also, I have checked:

    nginx -V 2>&1 | grep -- 'http_realip_module' 
    nginx -V 2>&1 | grep -- 'stream_realip_module' 
    (stream_realip_module is not contained by default nginx, but I didn't use the stream directive in nginx.conf)