Can't see original visitor IPs with Nginx setup

Not sure what I’m doing wrong
site-setup

server {

listen       8080;
server_name  localhost;
  location / {
  rewrite ^(.*)$ $1?ip=$remote_addr break; 
    proxy_pass http://127.0.0.1:2052/;
    proxy_redirect     off;
    proxy_set_header   Host                  $http_host;
    proxy_set_header   X-Real-IP        $remote_addr;
    proxy_set_header   X-Forwarded-For  $remote_addr;
    access_log off;
    log_not_found off;
  }
}

and in conf.d I create cloudflare.conf

set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 104.16.0.0/12;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 131.0.72.0/22;
set_real_ip_from 141.101.64.0/18;
set_real_ip_from 162.158.0.0/15;
set_real_ip_from 172.64.0.0/13;
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 188.114.96.0/20;
set_real_ip_from 190.93.240.0/20;
set_real_ip_from 197.234.240.0/22;
set_real_ip_from 198.41.128.0/17;

set_real_ip_from 2400:cb00::/32;
set_real_ip_from 2405:8100::/32;
set_real_ip_from 2405:b500::/32;
set_real_ip_from 2606:4700::/32;
set_real_ip_from 2803:f800::/32;
set_real_ip_from 2c0f:f248::/32;
set_real_ip_from 2a06:98c0::/29;

real_ip_header CF-Connecting-IP;

and nginx.conf includes

include                         /etc/nginx/conf.d/*.conf;
include                         /etc/nginx/sites-enabled/*;

is there something I’m missing, some tutorial to follow

any suggestions?

Are you connecting to your origin via DNS records or via a tunnel?

1 Like

Not sure if it’s the root cause of your problem, but you are missing one of the IPv4 blocks (you have 14, there are 15)…

(I recall someone else had the same so maybe you are copying your configuration from the same place which has an out of date list).

2 Likes

via Tunnel

@sjr added, but didn’t make a difference

The tunnel doesn’t use Cloudflare IPs but connects from 127.0.0.1.

can you elaborate further

there’s no way to do this with my setup, or I need to do this different way?

set_real_ip_from 127.0.0.1

Delete the other entries.

hmm no luck

still IP address of host is in database

Which address do you find? That IP is what you need to use in set_real_ip_from.

2 Likes

holly s*** that worked

set_real_ip_from 192.168.0.112;

thank you sir!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.