views:

301

answers:

2

Good day,

I have two resin servers - r-server-a and r-server-b. I created two because both have web applications that need to be in the root context path '/' (and using same port '80').

However, both web applications need to see each other (i.e. access the other application's resources & pages). Which is why I thought I'd use an apache server to handle the two.

How do I do that?

Thanks

A: 

What you need is mod_proxy in Apache, in the apache config (like the virtual host config) put:

ProxyPass / http://localhost:8080/<web-app context root>/
ProxyPassReverse / http://localhost:8080/<web-app context root>/
John Paulett
Pardon, but how can I configure apache to forward for example http://localhost/this/is/page1.html to r-server-a and http://localhost/this/is/another/page.html to r-server-b using mod_proxy? Thanks
Franz See
Im trying to figure out how I can do it proxying with regex
Franz See
Possibly mod_rewrite can help, if you use mod_proxy to host localost/serverA and localhost/serverB, then use mod_rewrite to rewrite localhost/this/is/page1.html to localhost/serverA/page1.html and localhost/this/is/another/page.html to localhost/serverB/another/page.html. Complicated, but I think it will work.
John Paulett
A: 

Both using same port means not the same IP. that might be same machine two instances each bound to one NIC or two separate machines. This is not that clear from the question, however, it does not matter for that much.

For several reasons I would pick NGINx as a reversed proxy (instead of apache) and configure it accordingly.

See at tornado's documentation how they do that for tornado (in that case, 4 instances on each server) and copy the concept to your location. Good luck.

Tzury Bar Yochay
They are using the same IP. Both uses same ip, same port and both are in the root context path. However, the pages they are serving are different. For example r-server-a serves http://localhost/this/is/page1.html, while the other servers r-server-b http://localhost/this/is/another/page.html. However both needs to be up at the same time because http://localhost/this/is/page1.html can redirect to http://localhost/this/is/another/page.html and vice-versa. Furthermore, I cannot make turn those two applications inte one due to numerous conflicts (configuration-wise).
Franz See
that is true, but makes no difference. see, if you have two instances 127.0.0.1:8000 and 127.0.0.1:8001 they can be represented as 10.0.0.1:8000 and 20.0.0.1:8000 that is same machine, same port - yet different IP address. I see no way of running on the same machine two listeners on the same port binding to the same IP.
Tzury Bar Yochay
Franz See