Skip to content

Instantly share code, notes, and snippets.

@RaeesBhatti
Created August 1, 2015 22:43
Show Gist options
  • Save RaeesBhatti/e336ab920ab523335937 to your computer and use it in GitHub Desktop.
Save RaeesBhatti/e336ab920ab523335937 to your computer and use it in GitHub Desktop.
Allow HTTP and HTTPS from CloudFlare only (Ubuntu)
#!/bin/bash
for i in `curl https://www.cloudflare.com/ips-v4`; do ufw allow from $i to any port 80; done
for i in `curl https://www.cloudflare.com/ips-v6`; do ufw allow from $i to any port 80; done
## If you have setup Full or Strict SSL settings with CloudFlare, use this one also
for i in `curl https://www.cloudflare.com/ips-v4`; do ufw allow from $i to any port 443; done
for i in `curl https://www.cloudflare.com/ips-v6`; do ufw allow from $i to any port 433; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment