Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Running Node.js with Apache (OSQA)

velniukas edited this page Mar 26, 2012 · 1 revision

Following useful tips given on http://eastmond.org/blog/?p=45

Use Node to do forwarding for forum requests

npm install http-proxy

From the above blog:

"moved Apache over to port 9000 by editing /etc/apache/ports.conf

NameVirtualHost *:9000

Listen 9000

I also edited /etc/apache2/sites-enabled/000-default and updated the VirtualHost

<VirtualHost *:9000>

Restart Apache

sudo /etc/init.d/apache restart

And you should now see Apache running on port 9000

Since I don’t want to run Node as root, I added an iptables rule to forward requests for port 80 to port 3000

iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3000

To view the new rule use

iptables -t nat -L -n -v

And should you need to delete a rule, use the index of the rule from the previous command with this command

iptables -t nat -D PREROUTING RULE_INDEX_HERE"

For Node.js conditional URL forwarding - see

https://gist.github.com/952924