Skip to main content

Django reverse proxy

Project description


Django reverse proxy. Allows you to proxy any website behind a prefix.


- `Python <>`_ 2.x superior to 2.5 and Django
- `Django <>`_ >= 1.2
- `restkit <>`_ >= 2.1.2


Install from sources::

$ python install

Or from Pypi::

$ easy_install -U dj-revproxy


Add `revproxy` to the list of applications::



Since 0.2, there is 2 ways to use dj-revproxy.

1. Generic view

You can use ``proxy_request`` function to proxy any url. You can use it in your code::

proxy_request(request, "")

This code will proxy current request to ```` domain.
This function can take 5 parameters:

- destination: string, the proxied url. Required
- path: string, If no path is given it will try to detect the url using
the prefix if it's given. If not full request.path will be used in
finl destination url.
- prefix: string, the prrefix behind we proxy the path
headers: dict, custom HTTP headers
- no_redirect: boolean, False by default, do not redirect to "/"
if no path is given
- decompress: boolean, False by default. If true the proxy will
decompress the source body if it's gzip encoded.

It return an instance of ``django.http.HttpResponse``. You can use it directly
in your (which is the eaiest way to use). Ex::

(r'^gunicorn(?P<path>.*)', "revproxy.proxy_request", {
"destination": ""

2. Configure multiple proxy behind one generic prefix

To configure a proxy add a tupple to the REVPROXY_SETTINGS list::

("_google", ""),
("_friendpaste", ""),
("_couchdb", ""),

Then configure your proxied urls automatically do something like this in
from django.conf.urls.defaults import *

import revproxy

urlpatterns = patterns('',
(r'^proxy/', include(revproxy.site_proxy.urls)),

Which will allow you to proxy Google on the url::

or even::

('^proxy/(?P<prefix>[^\/]*)(.*)', "revproxy.site_proxy"),

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dj-revproxy-0.2.1.tar.gz (9.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page