I would like to run apache2 and a node.js app on my webserver simultaneously. I'd like my website on www.example.com/myApp to run my app (proxied from port 8080), and everything else on www.example.com/* to be run by apache (normally on port 80). I've read a couple of questions about this on StackOverflow but I couldn't get it to work properly.
I am using
yarn start --port 8080 --host 0.0.0.0 --disable-host-check
to start my app.
In order to do this I was changing values in my apache.conf file on my Ubuntu 18.04 VM. I am running my app with yarn.
I enabled
sudo a2enmod proxy && sudo a2enmod proxy_http
and I have these lines in my config file:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
ServerName example.com
ProxyPreserveHost On
ProxyRequests Off
If I add
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
to my apache.conf file, the app runs successfully on www.example.com. However, I can only access directories from the folder in which the app is installed/running. I cannot access apache's directories.
If instead I add
ProxyPass /myApp/ http://localhost:8080/
ProxyPassReverse /myApp/ http://localhost:8080/
then the app runs on www.example.com/myApp, which IS what I wanted, but it does not run correctly anymore, and I don't know why. Every other url on the website points to my apache dir (/var/www/html) which is also what I wanted.
The app always works properly on localhost:8080.
I have no experience with these things and it feels like I'm really close with the second solution, but I must be missing something since the app stops working correctly.