Skip to content

Instantly share code, notes, and snippets.

@viseshrp
Forked from Mearman/cloudflare_whitelist.sh
Created December 21, 2022 01:26
Show Gist options
  • Save viseshrp/d6b1800c8aa55c8185eeda9169a8bf6b to your computer and use it in GitHub Desktop.
Save viseshrp/d6b1800c8aa55c8185eeda9169a8bf6b to your computer and use it in GitHub Desktop.
NGINX Cloudflare Access whitelist
#!/bin/bash
cd /mnt/user/appdata/NginxProxyManager/nginx
echo "IPV4" >> new.conf
echo "" >> new.conf
curl -sSL https://www.cloudflare.com/ips-v4 | awk '{print "allow",$1,";"}' >> new.conf
echo "IPV6" >> new.conf
echo "" >> new.conf
curl -sSL https://www.cloudflare.com/ips-v6 | awk '{print "allow",$1,";"}' >> new.conf
mv new.conf allow.conf
cat allow.conf
include /config/nginx/allow.conf;
deny all;

The purpose of this script is to easily set up, update and use the Cloudflare IP's as a whitelist in NGINX (in this case NGINX Proxy Manager) to make the use of Cloudflare Access more secure.

In this scenario, NPM (NGINX Proxy Manager) is being hosted on an UnRAID system.

The script creates a file within the NPM's appdata directory. This can them be included in your chosen host under Abvanced > Custom Nginx Configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment