By chiKaRauT
I am trying setup Apache to have multiple routes/links/sub-directory for multiple apps (node.js app, react app)
For example,
And these apps would start on its individual ports like app1 runs on port 81, app2 runs on port 82,… and so on.
I had already try to create a virtualhost in /etc/apache2/sites-available/newRoute.conf
<VirtualHost *:80>
ServerName mydomainname.net
ServerAlias www.mydomainname.net
ServerAdmin name@hotmail.com
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://localhost:3000/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://localhost:3000/$1 [P,L]
ProxyPassReverse / http://localhost:3000/
</VirtualHost>
<VirtualHost *:80>
ServerName mydomainname.net/test
ServerAlias www.mydomainname.net/test
ServerAdmin name@hotmail.com
ProxyPass /test http://localhost:81/
ProxyPassReverse /test http://localhost:81/
</VirtualHost>
but it didn’t work out. I started the node.js app on port 81 and browse to mydomainname.net/test, and it just display my mydomainname.net content.
In addition, localhost:3000 is just a react app which has homepage content
Also, the node.js app which running on localhost:81 would print “hello world” on the screen.
Thank
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
@chiKaRauT Use Location tag as follows
<VirtualHost *:80>
ServerName mydomainname.net
ServerAlias www.mydomainname.net
ServerAdmin name@hotmail.com
<Location /projects/app1>
ProxyPass http://localhost:81/
</Location>
<Location /projects/app2>
ProxyPass http://localhost:82/
</Location>
</VirtualHost>
Hope this helps.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.