Thursday, 4 May 2017

How to set Node,js server to answer requests from domain

I have a domain set up to point to my server at home, by way of the router's public IP. I am forwarding port 80 to my server from the router.

I have a node.js server running on the target machine but I cannot get it to answer using a loopback (setting it to listen on localhost). It will only answer http requests through the domain if it is set to listen on all addresses (0.0.0.0). This is undesirable for obvious reasons but I cannot seem to get it working as it should and no amount of googling seems to yield the answer.

Do I need to add a clause to my hosts file like this? 127.0.0.1 mydomain

Should I set the server to listen for the domain name?

I feel like I am forgetting something stupid and would really appreciate some assistance. Also, not to be rude but I am not using express or any third party module for this so info utilizing built-in node modules/standards will be greatly appreciated.

Thanks!



via Turboman

No comments:

Post a Comment