Tsea Tsea - 4 months ago 16
Javascript Question

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

I have a nodejs api application running inside a codeigniter environment. Im trying to access the nodejs api's without using a port number in the url

currently you can only hit the node api at

http://wrl.xx.com:8010/api


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

http://wrl.xx.com/api/


I tried to run a reverse proxy with no success

<VirtualHost *:80>
ServerName wrl.xx.com

ProxyRequests off

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

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

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.

Comments