Tsea Tsea - 4 months ago 13
Node.js Question

How do I get nodejs to run without a port number on an Apache server

I have a nodejs api app running inside a codeigniter environment. I would like to be able to use my node js api's with out using a port number in the url

currently you can only hit the node api at

http://ec2-14-210-250-136.us-west-2.compute.amazonaws.com:8010/api/projects


And I would like to have it accessible through a url like :

http://ec2-14-210-250-136.us-west-2.compute.amazonaws.com/api/projects


I tried to run a reverse proxy with no success

<VirtualHost *:80>
ServerName ec2-14-210-250-136.us-west-2.compute.amazonaws.com

ProxyRequests off

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

ProxyPass / http://localhost:8010/
ProxyPassReverse / http://localhost:8010/
ProxyPreserveHost on
</VirtualHost>


This let me access the node api with the url I want but I can no longer access the home page of my codeigniter environment

Answer

Assuming you intend to differentiate requests looking for the nodejs app from requests seeking the codigniter app by seeing /api as the root path, try:

ProxyPass /api http://localhost:8010/api
ProxyPassReverse /api http://localhost:8010/api

See ProxyPass and ProxyPassReverse for more magic.