Last active
April 14, 2021 18:08
-
-
Save maxmichels/7080665e01ec0866d20d0b0593619e22 to your computer and use it in GitHub Desktop.
Cron Plesk / Nginx Allow Cloudflare set_real_ip_from
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Update the IP List for nginx config | |
# Allowed ips will be stored in /etc/nginx/conf.d/00_real_ip_cloudflare_00.conf | |
# File is imported by /etc/nginx/nginx.conf | |
echo "#Cloudflare" > /etc/nginx/conf.d/00_real_ip_cloudflare_00.conf; | |
for i in $(curl https://www.cloudflare.com/ips-v4 2>/dev/null); do | |
echo "set_real_ip_from $i;" >> /etc/nginx/conf.d/00_real_ip_cloudflare_00.conf; | |
done | |
for i in $(curl https://www.cloudflare.com/ips-v6 2>/dev/null); do | |
echo "set_real_ip_from $i;" >> /etc/nginx/conf.d/00_real_ip_cloudflare_00.conf; | |
done | |
echo "real_ip_header CF-Connecting-IP;" >> /etc/nginx/conf.d/00_real_ip_cloudflare_00.conf; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment