Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

deploying Node.js app for production

Tags:

node.js

Most of the tutorials I've come across, you set up a Node.js web app by setting the server to listen on a port, and access it in the browser by specifying that port.. However, how would I deploy a Node.js app to be fully accessible by say a domain like foobar.com?

like image 311
victormejia Avatar asked Nov 01 '25 03:11

victormejia


2 Answers

You have to bind your domain's apex (naked domain) and usually www with your web server's ip or it's CNAME.

Since you cannot bind apex domain with CNAME, you have to specify server IP or IPs or load balancers' IPs

like image 150
jwchang Avatar answered Nov 03 '25 20:11

jwchang


Your question is a little vague.. If your DNS is already configured you could bind to port 80 and be done with it. However, if you already have apache or some other httpd running on port 80 to serve other hosts that obviously won't work.

If you prefer to run the node process as non-root (and you should) it's much more likely that you're looking for a reverse proxy. My main httpd is nginx, the relevant option is proxy_pass. If you're using apache you probably want mod_proxy.

like image 30
nkuttler Avatar answered Nov 03 '25 19:11

nkuttler