Last active
January 13, 2016 19:36
-
-
Save analogrithems/bf13b57275ed2f157daa to your computer and use it in GitHub Desktop.
Generate an Nginx Geo list of Amazon IP's from their public JSON list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jq = document.createElement('script'); | |
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(jq); | |
setTimeout(function(){ | |
var jqxhr = jQuery.get( "https://ip-ranges.amazonaws.com/ip-ranges.json", function(data) { | |
var s = "geo $amazon {\n"; | |
var ni = []; | |
s += "\tdefault\t\t\t0;\n"; | |
for( var bean=0;bean<data.prefixes.length;bean++){ | |
var ipb = data.prefixes[bean]['ip_prefix']; | |
#No dupes | |
if(!ni[ipb]){ | |
s += "\t"+ipb+"\t\t\t1;\n" | |
ni[ipb]=1; | |
} | |
} | |
s += "}\n"; | |
console.log(s); | |
}) | |
}, 3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use this, go to https://ip-ranges.amazonaws.com/ip-ranges.json open chrome console and just paste it in