Visitor IPs not showing after following cloudflare guide

Hi everyone,

I’ve got a Cloudflare tunnel that forwards traffic to an nginx webserver. I’ve followed the guide here: https://developers.cloudflare.com/support/troubleshooting/restoring-visitor-ips/restoring-original-visitor-ips/

My nginx does have the http_realip_module module (I checked)
My nginx.conf file has the “set_real_ip_from x.x.x.x/x” lines for each ip from the list of Cloudflare IP’s as well as the ‘real_ip_header CF-Connecting-IP;’ line all in the http section.

I’ve set the log format to:

        log_format compression '$remote_addr - $http_cf_connecting_ip - $http_x_forwarded_for - $remote_user [$time_local] '
                           '"$request" $status $body_bytes_sent '
                           '"$http_referer" "$http_user_agent" "$gzip_ratio"';

I’ve restarted nginx, but in the access log, I’m not seeing the entry for $http_cf_connecting_ip & $http_x_forwarded_for they are both blank.

Any ideas on what I’m missing?

Thanks!

Nevermind. The issue was in the nginx.conf. There was an error in my log format directive so the custom directive was not being used. I fixed it and now the visitor ip addresses are showing up!

2 Likes