0

I'm working at a project in school that includes Apache server. All i need to do right now to start working with the server is create An index file (html, ph) at my folder on the server (inside the public_html) and the server will return that page.

but the thing is that I want to write the server with nodejs. I have already manage to install node on the server but I know how to ignore the Apache server and start working with node.

I read about that and I saw that i need to start node on a different port? or use proxy? but I really don't know that much about servers.

3
  • Yeah, u can just bind nodejs to a different port in your script or either stop Apache and run it through port 80 (default) or you can go down the long trip and play with proxies Commented Dec 20, 2014 at 11:38
  • @ryanc1256 you know how to do that? Commented Dec 20, 2014 at 11:42
  • what way do you want to go? Do Apache proxies or just just nodejs on port 80 Commented Dec 26, 2014 at 10:23

2 Answers 2

1

You can use apache as proxy for nodejs https://httpd.apache.org/docs/2.2/mod/mod_proxy.html.

ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/

Or, if you want to run the nodejs not from root directory of server

ProxyPass /mynodejsproject http://localhost:3000/
ProxyPassReverse /mynodejsproject http://localhost:3000/

For example, nodejs application listens on 3000 port, apache on 80 port, and it proxies requests to nodejs application.

But i recommend you to use nginx as proxy for nodejs application, this is the config i used in my projects https://github.com/vodolaz095/hunt/blob/master/examples/serverConfigsExamples/nginx.conf

Sign up to request clarification or add additional context in comments.

1 Comment

Also just a tip if you go down this way and you use websockets you also have to do ProxyPass for websockets as well, but i think in new Apache versions they have fixed it so that you can proxyPass it, but yeah just have a look into it, if your having problems with websockets
0

service apache2 stop Stops your apache server (It works on 80 port default)

Also there is a good tool for nodejs ,you will able to manage your nodeJS server(you can give 80 port now) like services with forever on nodeJS.(I assumed you know how to creating your nodejs http server)

3 Comments

Hey the thing is that because it a school server wont i stop like that the server for every one else? and BTW service is unknown command :\
probably you can stop it by systemctl stop apache - if it is rpm based repo
Then you will specify your port, here is a code snippets in nodejs doc.nodejs.org/api/http.html#http_class_http_server

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.