0

I am using Express framework to built my app and Forever to deploy it but it doesn't seem to work because im not using a cloud based computer as suggested on the internet like in this video : https://www.youtube.com/watch?v=XxRuW1pfGTI .

What I want to do is put my files on htdocs folder of Apache server that resides on my computer and host the website personally by using a tool like Forever and be done with it, but i think im missing something.

I read about mod_proxy to reverse proxy the URL but i dont like the idea because its just redirecting my IP to https:/localhost/3000/ which cant be the best way to do it.

Anyone can tell me what am I doing wrong or how its done correctly? Thanks

Edit1: what my question really comes down to (if it makes sense at all) is : what is making the node.js /bin/www file to listen to say port 3000 on "localhost" and how can i change this to my IP which is on the internet through Apache?

var port = normalizePort(process.env.PORT || '3000');

xtabbas
  • 627
  • 4
  • 10
  • 18
  • why would you need an apache in the first place? – Johannes Merz Sep 11 '16 at 05:53
  • I said Apache because its what I use for deploying PHP websites and its present on my computer. Do you have any suggestions? Why not Apache is what i would ask you. – xtabbas Sep 11 '16 at 06:00
  • but node has an already build in server. You can't let apache run your javascript for you. I can't think about anything but reverse proxing in this case. – Johannes Merz Sep 11 '16 at 11:49

1 Answers1

2

Just like you would not host a Java app in your htdocs dir via Apache, you can't put a Node.js app into your Apache htdocs dir and expect Apache to launch the Node.js runtime. Sure, it works that way with CGI scripts and PHP, thanks to mod_cgi and mod_php respectively. There's no mod_nodejs as far as I'm aware.

There are several options here, including the mod_proxy one. It sounds like your objection to that is basically an aesthetic objection. It's a fine way to go.

Another option is to ditch Apache entirely and use nginx to reverse proxy your Node.js app.

Some people might suggest not using a proxy at all and just letting your Node.js app be the server. I prefer to use a proxy for robustness/security. (See https://stackoverflow.com/a/16770780/436641.)

Community
  • 1
  • 1
Trott
  • 66,479
  • 23
  • 173
  • 212
  • `Some people might suggest not using a proxy at all and just letting your Node.js app be the server.` Yes how can i do that ? and also using `mod_proxy` is a blunder to setup for me as i keep running in troubles like conflicts between https:/localhost and http:/localhost – xtabbas Sep 11 '16 at 06:41