From b4342d40e0cd3c8f2184a70013e8f4a3bceaab21 Mon Sep 17 00:00:00 2001 From: Roxedus Date: Thu, 21 Jan 2021 18:47:11 +0100 Subject: [PATCH] SWAG-Real-IP: Better detection --- README.md | 2 +- root/etc/cont-init.d/98-cloudflare-real-ip | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1988bb5..f25911d 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ include /config/nginx/cf_real-ip.conf; ~~I also recommend including your docker-network as a valid ip `set_real_ip_from 172.17.0.0/16;` in the snippet above.~~ -This mod now also *tries* to set the real ip from the default route in the contaier. +This mod now also *tries* to set the real ip from the interfaces in the container. ## Versions diff --git a/root/etc/cont-init.d/98-cloudflare-real-ip b/root/etc/cont-init.d/98-cloudflare-real-ip index 541dbe1..fc85b8b 100644 --- a/root/etc/cont-init.d/98-cloudflare-real-ip +++ b/root/etc/cont-init.d/98-cloudflare-real-ip @@ -5,7 +5,7 @@ printf "set_real_ip_from %b;\n" $({ curl -s "https://www.cloudflare.com/ips-v4" & curl -s "https://www.cloudflare.com/ips-v6" & - echo "$(ip route get 1 | sed -n 's/^.*src \([0-9.]*\) .*$/\1/p' | sed 's/\.[0-9]*$//')/16" + ip route | grep -v default | awk '{print $1}' }) > /config/nginx/cf_real-ip.conf chown abc:abc /config/nginx/cf_real-ip.conf