Configuring Nginx Proxy Manager (npm) or Nginx to send the Real Client IP using Cloudflare Proxy

Tiempo de lectura: < 1 minuto

We will learn today how we can capture the real IP of the client passing through Cloudflare’s proxy and receiving it in Nginx Proxy Manager (NPM) or Nginx.

Snowy Mountain - pexels

We will open our reverse proxy and go to Proxy Hosts.

Proxy host nginx proxy manager

Now we select the proxy that we want to send real IPs and put it in Advanced.

In the Custom Nginx Configuration section, we need to add the following:

To show your backend the real client IP, you need to use CF-Connecting-IP and rely on Cloudflare ranges. Your configuration would look like this:

set_real_ip_from 03.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/13; set_real_ip_from 104.24.0.0/14; 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; #use any of the following two real_ip_header CF-Connecting-IP; #real_ip_header X-Forwarded-For;

NOW we click on Save

We will have the header available in x-real-ip

Leave a Comment