Skip to content

Instantly share code, notes, and snippets.

@Mearman
Last active February 25, 2024 15:23
Show Gist options
  • Save Mearman/522fff4d6144f6a480f777f39410fc5c to your computer and use it in GitHub Desktop.
Save Mearman/522fff4d6144f6a480f777f39410fc5c 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