0

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> 
2
  • DO NOT USE ProxyRequests On. This will enable forward-proxying which is NOT what you want. Commented Dec 15, 2016 at 23:09
  • @ChristopherSchultz Thanks, you're right I didn't need that Commented Dec 16, 2016 at 19:34

1 Answer 1

1

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> 
Sign up to request clarification or add additional context in comments.

5 Comments

But the how cant I get setup the RewriteCond for this. The RewriteRule should only affect the Ruby application (App2).
There was nothing about Rewrite in your question :). What URL exactly do you want to rewrite, and to what?
I'd like to rewrite the response coming back from http://192.168.0.62:3030/. The Rewrite in the question does that, but seems The problem is, the response header says the referrer is 192.168.0.62 so i had to use the Reverse definition from the question
I don't understand what are you trying to achieve (beside simple proxying to two backend apps, depending on the URI): mod_rewrite is rewriting requests, not responses; Referer: is request header, not response header. What exactly doesn't work if you just use the ProxyPass directives as above, can you give an example?
Thanks, I figured out that my issue isn't the app server as much as it is the application I'm trying to host.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.