I need to solve a simple DNS query using njs in nginx.
I've searched but it seems that there isn't a 'native' function for doing this.
So I'm trying to use dns-lookup
module for node.js
I've installed it using npm install dns-lookup
, then I've tried to use it in my njs script, with something like:
var lookup = require('dns-lookup');
ip = lookup.resolve(hostname);
But when I run this script I receive an error:
[error] 13555#13555: *124 js exception: Error: Cannot find module "dns-lookup"
1st question, is it right what I'm doing? How can I load an external module in my js file?
2nd question, do you know how to solve? And/or is there a better way for do a DNS resolution?
I've found a similar question here in stackoverflow but without answers
Thanks in advance