Skip to main content

Configure TCP → Proxy Rule

To see the real IP addresses of clients accessing the load balancer, you can create a TCP → Proxy rule and use the Proxy Protocol. Client information will be added to the connection header.

For more information, see the Changing the Load Balancer's IP Address to the Client IP Address guide in the nginx documentation.

  1. Make sure that you created a load balancer with the following parameters:

    • for the target group — PROXY protocol and port 80;
    • for the rule — TCP protocol and port 80.

    You can view available load balancers in the Control Panel: in the top menu, click Products → Cloud Servers → Load Balancers → Load Balancers tab.

  2. Connect to the cloud server from the target group.

  3. Install and configure nginx:

    apt update
    apt install nginx
    systemctl start nginx
  4. Open the configuration file on the cloud server:

    nano /etc/nginx/sites-enabled/default
  5. Change the lines in the server block:

    server {
    listen 80 proxy_protocol;

    set_real_ip_from <loadbalancer_ip_address>;
    real_ip_header proxy_protocol;

    ...
    }

    Specify <loadbalancer_ip_address> — the private IP address of the load balancer, for example 192.168.0.3. You can view it in the Control Panel: in the top menu, click Products → Cloud Servers → Load Balancers → Load Balancers tab → load balancer page → Settings section → Network field. It is used as a trusted address — for more information about the set_real_ip_from directive, see the nginx documentation.