'How get real IP when using nginx with aws cloudfront?

Using aws cloudfront. Need get real IP on nginx, tried did like this, but it not works for me. https://jonmoblog.wordpress.com/2020/05/19/how-to-unblock-your-cdn-and-detect-your-real-visitors/

This is what I am using

server { 
    listen 80;
    listen [::]:80;
    server_name mysite.com;
    root /var/www/;
set_real_ip_from 120.52.22.96/27;
set_real_ip_from 205.251.249.0/24;
set_real_ip_from 180.163.57.128/26;
set_real_ip_from 204.246.168.0/22;
set_real_ip_from 205.251.252.0/23;
set_real_ip_from 54.192.0.0/16;
set_real_ip_from 204.246.173.0/24;
set_real_ip_from 120.253.240.192/26;
set_real_ip_from 116.129.226.128/26;
set_real_ip_from 99.86.0.0/16;
set_real_ip_from 205.251.200.0/21;
set_real_ip_from 223.71.71.128/25;
set_real_ip_from 13.32.0.0/15;
set_real_ip_from 120.253.245.128/26;
set_real_ip_from 13.224.0.0/14;
set_real_ip_from 70.132.0.0/18;
set_real_ip_from 210.51.40.0/24;
set_real_ip_from 13.249.0.0/16;
set_real_ip_from 205.251.208.0/20;
set_real_ip_from 58.254.138.0/25;
set_real_ip_from 116.129.226.0/25;
set_real_ip_from 52.222.128.0/17;
set_real_ip_from 64.252.128.0/18;
set_real_ip_from 205.251.254.0/24;
set_real_ip_from 71.152.0.0/17;
set_real_ip_from 216.137.32.0/19;
set_real_ip_from 204.246.172.0/24;
set_real_ip_from 120.52.39.128/27;
set_real_ip_from 118.193.97.64/26;
set_real_ip_from 223.71.71.96/27;
set_real_ip_from 130.176.0.0/16;
set_real_ip_from 54.240.128.0/18;
set_real_ip_from 205.251.250.0/23;
set_real_ip_from 180.163.57.0/25;
set_real_ip_from 52.46.0.0/18;
set_real_ip_from 223.71.11.0/27;
set_real_ip_from 52.82.128.0/19;
set_real_ip_from 54.239.128.0/18;
set_real_ip_from 36.103.232.128/26;
set_real_ip_from 52.84.0.0/15;
set_real_ip_from 111.51.66.0/24;
set_real_ip_from 143.204.0.0/16;
set_real_ip_from 144.220.0.0/16;
set_real_ip_from 120.52.153.192/26;
set_real_ip_from 119.147.182.0/25;
set_real_ip_from 120.232.236.0/25;
set_real_ip_from 54.182.0.0/16;
set_real_ip_from 58.254.138.128/26;
set_real_ip_from 120.253.245.192/27;
set_real_ip_from 54.239.192.0/19;
set_real_ip_from 120.52.12.64/26;
set_real_ip_from 99.84.0.0/16;
set_real_ip_from 54.230.0.0/16;
set_real_ip_from 52.124.128.0/17;
set_real_ip_from 204.246.164.0/22;
set_real_ip_from 13.35.0.0/16;
set_real_ip_from 204.246.174.0/23;
set_real_ip_from 36.103.232.0/25;
set_real_ip_from 119.147.182.128/26;
set_real_ip_from 118.193.97.128/25;
set_real_ip_from 120.232.236.128/26;
set_real_ip_from 204.246.176.0/20;
set_real_ip_from 120.253.241.160/27;
set_real_ip_from 13.124.199.0/24;
set_real_ip_from 35.167.191.128/26;
set_real_ip_from 18.200.212.0/23;
set_real_ip_from 99.79.169.0/24;
set_real_ip_from 52.15.127.128/26;
set_real_ip_from 34.223.12.224/27;
set_real_ip_from 54.233.255.128/26;
set_real_ip_from 13.54.63.128/26;
set_real_ip_from 13.59.250.0/26;
set_real_ip_from 3.234.232.224/27;
set_real_ip_from 52.66.194.128/26;
set_real_ip_from 13.228.69.0/24;
set_real_ip_from 64.252.64.0/18;
set_real_ip_from 18.216.170.128/25;
set_real_ip_from 3.231.2.0/25;
set_real_ip_from 52.220.191.0/26;
set_real_ip_from 34.232.163.208/29;
set_real_ip_from 35.162.63.192/26;
set_real_ip_from 34.223.80.192/26;
set_real_ip_from 34.226.14.0/24;
set_real_ip_from 13.113.203.0/24;
set_real_ip_from 34.195.252.0/24;
set_real_ip_from 52.52.191.128/26;
set_real_ip_from 52.56.127.0/25;
set_real_ip_from 34.216.51.0/25;
set_real_ip_from 52.199.127.192/26;
set_real_ip_from 52.212.248.0/26;
set_real_ip_from 13.210.67.128/26;
set_real_ip_from 35.158.136.0/24;
set_real_ip_from 52.57.254.0/24;
set_real_ip_from 52.78.247.128/26;
set_real_ip_from 52.47.139.0/24;
real_ip_header X-Forwarded-For;
real_ip_recursive on;

But when checking dont getting real IP. If anyone have experience cloudfront+nginx please help



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source