Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install dj-revproxy

How to install dj-revproxy

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install dj-revproxy
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.2.1 Available View build log
0.2.0 Failed View build log
0.1.1 Failed View build log
Windows (64-bit)
0.2.1 Available View build log
0.2.0 Failed View build log
0.1.1 Failed View build log
Mac OS X (10.5+)
0.2.1 Available View build log
0.2.0 Failed View build log
0.1.1 Failed View build log
Linux (32-bit)
0.2.1 Available View build log
0.2.0 Failed View build log
0.1.1 Failed View build log
Linux (64-bit)
0.2.1 Available View build log
0.2.0 Failed View build log
0.1.1 Failed View build log
 
License
BSD
Imports
Lastest release
version 0.2.1 on Jan 5th, 2011

dj-revproxy

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

Requirements

Installation

Install from sources:

$ python setup.py install

Or from Pypi:

$ easy_install -U dj-revproxy

Configuration

Add revproxy to the list of applications:

INSTALLED_APPS = (
    ...
    'revproxy'
)

Usage

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, "http://example.com")

This code will proxy current request to http://example.com 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 urls.py (which is the eaiest way to use). Ex:

(r'^gunicorn(?P<path>.*)', "revproxy.proxy_request", {
    "destination": "http://gunicorn.org"
}),
2. Configure multiple proxy behind one generic prefix

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

REVPROXY_SETTINGS = [
    ("_google", "http://google.com"),
    ("_friendpaste", "http://www.friendpaste.com"),
    ("_couchdb", "http://127.0.0.1:5984"),
]

Then configure your proxied urls automatically do something like this in urls.py:

System Message: ERROR/3 (<string>, line 81)

Unexpected indentation.
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:

http://127.0.0.1:8000/proxy/_google

or even:

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

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.