atd atd - 1 month ago 9
Linux Question

how to asisgn dns to ip on nginx using node.js

I was wondering how to assign my domain name to my nginx webserver that running node.js on it, I am using ubuntu and I have already installed dns server ,
as you know every application on node.js uses specific port ,
more details:

I have domain name (example.com) and I have server ip 1.1.1.1:55 , my domain points to 1.1.1.1 , but I want that when i enter example.com , it shows details of my website that are in the 1.1.1.1:55 , I dont know how to do it.I can access to my website details through ip:port but i dont know how to make it to be accessed from domain name (example.com)

so how may I do it?

Answer

I just found your answer here : How to assign a domain name to node.js server?

Quote:"

You dont assign a domain to a node.js server, instead you load your app onto a machine which has an ip adress, which in your case is 42.12.251.830:4000. You then need to make sure your app is listening on the correct port, which on most servers is 80

using express it's as simple as

var app = express()
  , server = require('http').createServer(app)
  , io = io.listen(server);

app.get('/', function(req, res) {
  res.sendfile('./public/index.html');
});
server.listen(80);

"

Comments