Node js & Apache In Parallel?

I have written a Node JS server waiting to sit on a server. In an ideal world, I'd like to create a sub-domain which points to the Node server. I have seen articles that allow you to v-host Apache to proxy forward to the node server on a specific port / port.

Example:

<VirtualHost 109.74.199.47:80>
ServerAdmin [email protected]
ServerName thatextramile.be
ServerAlias www.thatextramile.be

ProxyRequests off

<Proxy *>
    Order deny,allow
    Allow from all
</Proxy>

<Location />
    ProxyPass http://localhost:3000/
    ProxyPassReverse http://localhost:3000/
</Location>

http://thatextramile.be/blog/2012/01/hosting-a-node-js-site-through-apache/

People are suggesting however, that this isn't the best method as Apache's process will block until node has responded. Also it seems to be problematic with ajax requests.

Is there another way to point a sum-domain to Node JS without using Apache? Would it cause a problem if Node sits on port x and Apache on ports 80 and 443? Would they ever conflict?

Answers:

Answer

Try this

1.- Create subdomain directory and put to it your plesk subdomain rootdir.

2.- Put there your dist

3.- Choose and change the NODE.js port (In your env variables (in /server/config) and open it in Firewall access rules in Parallels plesk

4.- Go to your subdomain in parallels plesk and Enter web Server config

5.- In the aditional directives for http, put this:

RewriteEngine on
RewriteCond %{SERVER_NAME} yoursub.domain.com
RewriteCond %{SERVER_PORT} !8750 <-- CHOOSE YOUR PORT NUMBER AND CHANGE
RewriteRule ^/(.*) http://yoursub.domain.com:8750/$1 [P,R]

RewriteCond %{SERVER_PORT} 8750   <-- CHOOSE YOUR PORT NUMBER AND CHANGE
RewriteRule ^/(.*) http://yoursub.domain.com:8750/$1 [P,L]  <-- CHOOSE YOUR PORT NUMBER AND CHANGE

Then restart apache. And try it :) hope it helps and to not missing anything

EDIT To your answer about if there is any problem with apache before node.js. -> Not for me. Apache and node.js run great together. At least for me.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.