Help me understand how to use ProxyPass

apache-2.2djangomod-proxyPROXYproxypass

UPDATE: I added a revised question after playing around with it two answers below.

Hi there,

If you're reading this you're probably familiar with Apache's mod_proxy and its ProxyPass function. Like many others, I have the issue of having an application that I can access from outside our internal network, but that application itself accesses other internal apps on different machines, and when you get into remote access with this setup, things go wonky.

So, my setup is very simple, I have:

Machine #1 has remote access enabled, I access it through a host name and it spits out the PHP application running on it.

Machine #2 is a new application running Django, it uses an entirely different backend (even auth), it is hosted on a seperate machine. In our intranet, we access it through a simple named hostname which basically links to the internal 192.168.0.101 ip.

I've tried playing with ProxyPass to set it up so for example, a pass to /new would send it to the new application:

ProxyPass /new http://192.168.0.101/

This kind of works, it gets the request to the other app, but it breaks because my Django app wants to redirect to /auth/login/, which it instantly does not recognize. If I modify the url myself to be foo.net/new/auth/login I get my login page, but as you can guess doing this throughout browsing is not convenient.

So how can I get ProxyPass to work as I want? Do I need to do something with Apache so it always writes /new before url's in the other app, or is this something I should modify within my Django app?

Any tips and pointers as well would be greatly appreciated. Thanks for your time

Best Answer

You should modify your django application to expect to be at /new/auth/login instead of /auth/login. Generally your proxy passes should look like so:

ProxyPass /path http://192.168.0.101/path
ProxyPassReverse /path http://192.168.0.101/path

That combined with your Django app expecting to be at /new/ should fix your issues.

Related Topic