Setting up real-ip nginx module with CloudFlare.

If you want to get the real IP-address of the client accessing your website when using Cloudflare, you have to set up the Module ngx_http_realip_module.

Edit the file: /etc/nginx/nginx.conf  and add the following lines:

Create a new file: /etc/nginx/cloudflare  And add the following:

if you don’t have IPv6 enabled on your web-server. Remove the lines with the IPv6 addresses.

Keep in mind that these IP-addresses can change, so se the  list of IP addresses currently used by CloudFlare.


Reload the  ngnix service:

To verify that its working:

Confirm that you can see the IP-addresses of clients visiting your site.