Skip to main content
Configure TCP → Proxy rule
Last update:

Configure TCP → Proxy rule

To see the actual IP addresses of clients that access 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 Change Load Balancer IP Address to Client IP Address instruction in the nginx documentation.

  1. Create load balancer. When configuring load balancer rules specify:

    • The protocol for the load balancer is TCP;
    • The port for the load balancer is 80;
    • The protocol for the servers is `PROXY';
    • the port for servers is 80.
  2. Connect to the cloud server from the rule.

  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 <amphora_ip_address>;
    real_ip_header proxy_protocol;

    ...
    }

    Specify <amphora_ip_address> — the IP address of the load balancer, for example 192.168.0.3. You can look in control panel under Cloud PlatformBalancers → load balancer page. Used as a trusted address — more about set_real_ip_from directive in the nginx documentation.