0

I am running a java web application on tomcat 7.0, which is setup on media temple Ubuntu 16.04 server. The application is running on port 8080, and I have a domain which is binded to the port. e.g. public-ip-of-server:8080 xyz.com Now, I want to run a node js application (rocket-chat) on the same Linux server using port 3000. I have configured the whole application, and the application is running on localhost:3000/ but when I am trying to access the application using public IP of the server (e.g. public-ip:3000/), I am not able to access it.

I have allowed the traffic on port 3000 using command,

ufw allow 3000

I also edited apache2.conf,

ProxyPass /rocketchat http://public-ip-of-server:3000/ 
LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module
modules/mod_proxy_http.so

but after changing this parameter I am not able to restart the apache2 service. so I revert back the changes.

what should I do to run both the application (java and node js) on the same Linux server ? can anyone please help me out.

Raxit Solanki
  • 434
  • 6
  • 15

3 Answers3

0

Just bind nodejs app to interface 0.0.0.0 instead of 127.0.0.1.

Sergey Yarotskiy
  • 4,536
  • 2
  • 19
  • 27
0

In your Apache configuration, you should use the localhost instead of public ip. So instead of:

ProxyPass /rocketchat http://public-ip-of-server:3000/ 

use:

ProxyPass /rocketchat http://localhost:3000/ 
Nadir Latif
  • 3,690
  • 1
  • 15
  • 24
0

I am using Ubuntu server so httpd.conf is not present there, so I have created another file, in sites-available folder of apache2.(e.g xyz.conf). I have two domain which pointing to the same media temple name server, I used one domain for pointing tomcat application on port 8080 and another domain for node js application on port 3000, by making virtual host in xyz.conf

<VirtualHost *:80>
    ServerName  xyz.com
    ProxyPass / http://localhost:3000/
     ProxyPassReverse / http://localhost:3000/
</VirtualHost>
<VirtualHost *:80>
    ServerName  abc.com
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/
</VirtualHost>

After this I enabled proxy mode using command :

sudo a2enmod proxy

And also make this xyz.conf file as site configuration file, using command,

sudo a2ensite xyz.conf

It will ask you to reload the apache2 service, just reload it and restart,

e.g sudo systemctl restart apache2.service

The problem resolved by forwarding the request, which is received on port 80 of apache2, to tomcat:8080 and nodejs:3000, by creating virtual host.

Raxit Solanki
  • 434
  • 6
  • 15