Cloudflare configuration for pass real ip #2540
Replies: 4 comments
-
Seems reasonable to me, and I can't think of a cleaner way to do it unfortunately. |
Beta Was this translation helpful? Give feedback.
-
Hello @MaksimKiselev, Can you be more specific please when it comes to? What is the whole command to be used? Thanks |
Beta Was this translation helpful? Give feedback.
-
@MaksimKiselev This method is not enough. As stated in https://support.cloudflare.com/hc/en-us/articles/200170786-Restoring-original-visitor-IPs the list of cloudflare IPs in |
Beta Was this translation helpful? Give feedback.
-
Following @MaksimKiselev comment, using the Cloudflare API I wrote a bash/python3 command to generate the configuration file so that it can be dynamically created and updated. The following code assumes that the python3 -c "print('\\n'); import requests; response = requests.get('https://api.cloudflare.com/client/v4/ips'); response.raise_for_status(); data = response.json(); x = [print('set_real_ip_from ' + cidr + ';') for cidr in data['result']['ipv4_cidrs']]; x = [print('set_real_ip_from ' + cidr + ';') for cidr in data['result']['ipv6_cidrs']]; print('real_ip_header CF-Connecting-IP;\\n')" > ./cloudflare.conf |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi guys, I didn't find solution for this case and wanna show how I was resolved this.
I have configuration:
Cloudflare [HTTP] => nginx-proxy [HTTP] => site [HTTP]
Troubles:
On site I see IP of nginx-proxy container.
Solution:
Create additional configuration file like this:
Actual IP ranges you can find on page https://www.cloudflare.com/ips/
save as
cloudflare.conf
and add volume to nginx-proxy container:- /path/to/cloudflare.conf:/etc/nginx/conf.d/my.conf
Then for site container add to nginx configuration next lines:
Ok, it's worked)
Have ideas or recomendations?
Beta Was this translation helpful? Give feedback.
All reactions