rubyapachetomcatdashing

Host 2 application under one domain Apache HTTPD


I'm trying to configure Apache HTTPD 2.4 to front two different applications being hosted on the same server.

App1 is reachable on port 8080 (Tomcat)

mysingledomain.com:8080

App2 is reachable on port 3030 (Ruby [Dashing])

mysingledomain.com:3030

What I want to do is reach them respectively as mysingledomain.com/App1 and mysingledomain.com/App2

My situation is a lot like how this question start: Host 2 Sites in HTTPD

These are both SPA applications but I'm getting quite confused on how to set this up when I do not have a DocumentRoot to separate the configuration.

How would I setup HTTPD to front the HTTP requests in this manner?

I was able to configure the ruby application to adhere to a subpath with the following configuration, but this affects the other:

<VirtualHost *:80>
  ProxyRequests On # <---- WARNING DO NOT DO THIS
  ProxyVia On
  ProxyPreserveHost On
  RewriteEngine On

  ProxyPass "/app2"  "http://192.168.0.62:3030/" retry=0
  ProxyPassReverse "/app2/"  "http://192.168.0.62/"

  RewriteRule   "^/assets/(.*)"    "/app2/assets/$1"  [R]
  RewriteRule   "^/views/(.*)"    "/app2/views/$1"  [R]
</VirtualHost>

Solution

  • It should be as simple as this:

    <VirtualHost *:80>
      ServerName mysingledomain.com
      ProxyPreserveHost On
    
      ProxyPass /App1/  http://127.0.0.1:8080/
      ProxyPassReverse /App1/  http://127.0.0.1:8080/
    
      ProxyPass /App2/  http://127.0.0.1:3030/
      ProxyPassReverse /App2/  http://127.0.0.1:3030/
    </VirtualHost>