We generally use port 80 for http server, and use other port for the Node.js application, ex: localhost:443 for the chat application.

chat nodejs

How don’t use the port that could enter the nodejs application. We can use the modules mod_proxy and mod_proxy_http of apache.

Step 1: configuration the file httpd.conf (ex: D:\AppServ\Apache2.2\conf\httpd.conf)

LoadModule proxy_module modules/
#LoadModule proxy_ajp_module modules/
#LoadModule proxy_balancer_module modules/
#LoadModule proxy_connect_module modules/
LoadModule proxy_http_module modules/
#LoadModule proxy_ftp_module modules/
LoadModule negotiation_module modules/
LoadModule rewrite_module modules/
LoadModule setenvif_module modules/
#LoadModule speling_module modules/
#LoadModule status_module modules/
#LoadModule unique_id_module modules/
LoadModule userdir_module modules/
#LoadModule usertrack_module modules/
LoadModule vhost_alias_module modules/

apache config

Step 2: configuration the file httpd-vhosts.conf (ex: D:\AppServ\Apache2.2\conf\extra\httpd-vhosts.conf)

vhost config

Add following lines:

<VirtualHost *:80>
    ServerName chat.localhost
    ProxyRequests off
    <Proxy *>
        Order deny,allow
        Allow from all
    <Location />
        ProxyPass http://localhost:443/
        ProxyPassReverse http://localhost:443/

However, in some cases, all located in the httpd.conf file.

Step 3: restart apache (httpd service)

Now we can access the link: http://chat.localhost

apache nodejs

So, we can deploy multiple websites node.js on one server by using Apache.