adamhalasz/diet

Wrong ip Detected inside Containers

Closed this issue · 2 comments

listen('http://address.tld') fails inside linux namespace and lxc containers it gets the ip reversing to the hostname address.tld but it dont needs to run on same ip as the domain points too. So this needs removement for Production use cases where domain reverse dns ip is not the same as app ip

listen on ip first and then on the hosts fixes this but i think in general this needs fixing.

Goal is. Running adiet.js ap with only listen('http://bla.com')

suggestion to archiv this is to simply listen on all ips by default and not localhost
you probally setted localhost for your own testing.
if nothing is binded and we whant to bind a domain string then we need to bind to 0.0.0.0 first so all devices not only 127.0.0.1

events.js:160
throw er; // Unhandled 'error' event
^

Error: listen EADDRNOTAVAIL 5.x.x.x:80
at Object.exports._errnoException (util.js:896:11)
at exports._exceptionWithHostPort (util.js:919:20)
at Server._listen2 (net.js:1233:19)
at listen (net.js:1282:10)
at net.js:1392:9
at GetAddrInfoReqWrap.asyncCallback as callback
at GetAddrInfoReqWrap.onlookup as oncomplete
root@40fe87196f3c:/app#

Hey @frank-dspeed

I had the same issue before but I just quickly solved it by assigning the exact IP/Hostname to app.listen().

However you make a really good point. I just updated diet to v0.10.6. It listens on 0.0.0.0:$PORT so you can access your Server Instance with any hostname (127.0.0.1, localhost, test.com etc.) and you can still listen on specific Hostnames (subdomain.test2.com) to serve separate resources for different hostnames for example to work with subdomains.

I hope this patch resolves your issue. Let me know how it works for you and if you have any other questions.

Kind Regards,
Adam

ya its the same what i did i simply implemented: listen('0.0.0.0')
thats great !