Forked from radiofrequency/nginx_config_cloudfront_real_ips.js
Created
April 17, 2018 08:47
-
-
Save binarweb/bf17c685ce34e578b1bca2dfb1e786cb 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