Created
February 5, 2018 07:39
-
-
Save radiofrequency/3d582a118b8e9714898794e0afe94ddd to your computer and use it in GitHub Desktop.
list cloufront ip ranges for nginx real ip module
This file contains hidden or 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 request = require("request"); | |
var fs = require("fs"); | |
var output = "#cloudfront ip ranges\n"; | |
request("https://ip-ranges.amazonaws.com/ip-ranges.json", function(err, res, body) { | |
if (err) { | |
console.error("error", err); | |
} | |
var j = JSON.parse(body); | |
j.prefixes.forEach(function(item) { | |
if (item.service ==='CLOUDFRONT') { | |
output += "set_real_ip_from " + item.ip_prefix + ";\n" | |
} | |
}) | |
fs.writeFileSync(__dirname + "/etc/cloudfront_ips", output); | |
console.log("write cloudfront ips"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment