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.
- For HTTP
- For HTTPS
-
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
.
- The protocol for the load balancer is
-
Connect to the cloud server from the rule.
-
Install and configure nginx:
apt update
apt install nginx
systemctl start nginx -
Open the configuration file on the cloud server:
nano /etc/nginx/sites-enabled/default
-
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 example192.168.0.3
. You can look in control panel under Cloud Platform → Balancers → load balancer page. Used as a trusted address — more about set_real_ip_from directive in the nginx documentation.
-
Create load balancer. When configuring load balancer rules specify:
- The protocol for the load balancer is
TCP
; - The port for the load balancer is
443
; - The protocol for the servers is `PROXY';
- the port for servers is `443'.
- The protocol for the load balancer is
-
Connect to the cloud server from the rule.
-
Install and configure nginx:
apt update
apt install nginx
systemctl start nginx -
Open the configuration file on the cloud server:
nano /etc/nginx/sites-enabled/default
-
Change the lines in the
server
block:server {
listen 443 ssl proxy_protocol;
ssl_certificate /etc/nginx/ssl/public.example.com.pem;
ssl_certificate_key /etc/nginx/ssl/public.example.com.key;
set_real_ip_from <amphora_ip_address>;
real_ip_header proxy_protocol;
...
}Specify
<amphora_ip_address>
— the IP address of the load balancer, for example192.168.0.3
. You can look in control panel under Cloud Platform → Balancers → load balancer page. Used as a trusted address — more about set_real_ip_from directive in the nginx documentation.