Skip to content

Instantly share code, notes, and snippets.

@takinbo
Created October 22, 2024 07:46
Show Gist options
  • Save takinbo/9e9cb4cdde239756d5f5bfe0bcb82913 to your computer and use it in GitHub Desktop.
Save takinbo/9e9cb4cdde239756d5f5bfe0bcb82913 to your computer and use it in GitHub Desktop.
script for generating the snippet to include in the nginx configuration file for using the real ip address when logging access.
#!/usr/bin/env bash
for ip in $(curl -s https://www.cloudflare.com/ips-v4/); do
echo "set_real_ip_from $ip;";
done
for ip in $(curl -s https://www.cloudflare.com/ips-v6/); do
echo "set_real_ip_from $ip;";
done
echo "real_ip_header X-Forwarded-For;"
echo "real_ip_recursive on;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment