0

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?

Zong
  • 6,160
  • 5
  • 32
  • 46
Franz See
  • 3,282
  • 5
  • 41
  • 48

2 Answers2

0

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
  • 15,596
  • 4
  • 45
  • 38
  • 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 Nov 17 '09 at 04:10
  • Im trying to figure out how I can do it proxying with regex – Franz See Nov 17 '09 at 06:23
  • 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 Nov 17 '09 at 13:01
0

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
  • 8,798
  • 5
  • 49
  • 73
  • 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 Nov 17 '09 at 04:08
  • 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 Nov 17 '09 at 10:24
  • I dont need them to run on different servers,just be accessible with same ip & port.Which is why Im trying to use apache as a proxy/virtualhost/etc to accept urls such as 127.0.0.1:80/this/is/page1.html and allow my r-server-a to handle it (i.e. via url rewrite,proxy,caucho module,etc) & accept urls such as 127.0.0.1:80/this/is/another/page.html and have it handled by my r-server-b. My apache will run on 127.0.0.1. but my resin servers can run on 127.0.0.1:8081 and 127.0.0.1:8082 (for example).I just need to make to web applications w/ the same context path accessible using same ip & port. ty – Franz See Nov 17 '09 at 11:11