Reverse Proxy in Apache

By | 1 August, 2016

Scenario:

I have an apache server running on 127.0.0.1 (localhost) that i want to use to access a python/django project that is being served on a private server on localhost:8000 (specifically at /museus).

On my browser, i want to type:

localhost/museus

and it magically shows me what’s on localhost:8000/museus, without letting me know that there are actually two servers at work.
You can do it by using apache’s reverse proxy.

Note: I am using Wamp with Apache 2.4.9 on windows 8, but the configuration is identical on other versions/OSs/rooms

Another note: the private server can be anything else, obviously. I am using python/django as a test case.

First, edit your apache configuration file (in my case: httpd.conf). If you dont know where it is, see this post.

Remove comments from the loading of the following modules:

This:

#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_http_module modules/mod_proxy_http.so

should become this:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

(notice the missing #s)

At the end of the file, add:

ProxyPass /museus http://localhost:8000/museus
ProxyPassreverse / http://localhost:8000/

Please note that these lines are sufficient for my project, but your particular case will surely differ. Also note that this post doesn’t reflect the full potential of reverse proxy, but its merely a simple solution for a very specific problem.

You: “So cool! How can i learn more?”
Me: “Well, you can go read this:”

Configure Apache HTTPd as a reverse proxy (mod_proxy) (although this is for a specific apache server, the configuration is the same and its a simple read. But dont read just this if you want to learn more)
Apache mod_proxy – This is where you learn more.