Skip to content

Instantly share code, notes, and snippets.

@maxmichels
Last active April 14, 2021 18:08
Show Gist options
  • Save maxmichels/7080665e01ec0866d20d0b0593619e22 to your computer and use it in GitHub Desktop.
Save maxmichels/7080665e01ec0866d20d0b0593619e22 to your computer and use it in GitHub Desktop.
Cron Plesk / Nginx Allow Cloudflare set_real_ip_from
#!/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