Redhat with a reverse proxy, a specific configuration

redhatreverse-proxy

The setup I am trying to put together consists on a server connected to the internet (a redhat box) and 2 Apache Tomcat boxes not connected to the internet.

Let's call the server Server and the two Apache Tomcats, Apache1 and Apache2.

So, assuming my external IP is 102.1.1.1, Apache1 is 10.1.1.1 and Apache2 is 10.1.1.2, what I'm trying to configure is a reverse proxy so that if the request goes into http://102.1.1.1/mywebserver1/ it will be directed to Apache1 and if the request goes into http://102.1.1.1/mywebserver2/ it will be forwarded to Apache2.

Now, I don't need a cache on the proxy since there is application sitting in those tomcats and each request needs to get a fresh answer.

I searched for a while and I tried building this with Squid but i can't get it to work the way I need it.

Anyone knows how to do this? What software do I need? How do I configure the reverse proxy?

Thanks!

jessica

EDIT: Maybe I am better using mod_jk or mod_proxy to do this? I mean, can I have Apache install in Server and redirect the requests to Apache1 and Apache2 (Tomcat)?

Best Answer

Jessica, as you suggested in your edit, you can definitely use mod_proxy to do this. You would install Apache HTTPD on the server with the external IP and configure the reverse proxy to pass requests based on Locations defined in the httpd.conf file.

I really like this page as it gives an in-depth discussion of this topic while being a bit more helpful than just reading the configuration reference.

I suspect you can possibly configure mod_jk to do this, but I have not attempted that.

BASIC CONFIG

LoadModule proxy_module modules/mod_proxy.so

ProxyRequests Off
<Proxy *>
  Order deny,allow
  Allow from all
</Proxy>

ProxyPass /mywebserver1 http://10.1.1.1
ProxyPass /mywebserver2 http://10.1.1.2
ProxyPassReverse /mywebserver1 http://10.1.1.1
ProxyPassReverse /mywebserver2 http://10.1.1.2

You should read the httpd docs about ProxyPass and ProxyPassReverse directives. The ProxyPassReverse is especially interesting as it is a critical part of "cleaning up" the proxied traffic so that the apps being proxied don't have to know that they're being proxied. You may also be interested in mod_proxy_html

Related Topic