Install & Compatibility
Where this runs
tested against v0.13.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 67.3MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 3.6s · import 0.000s · 68MB
67MB installed
● package 67MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default_app_config
✓ from revproxy import default_app_config
✗ from revproxy import RevProxy
This quickstart demonstrates how to add `django-revproxy` to your Django project. First, add 'revproxy' to your `INSTALLED_APPS`. Then, define a URL pattern in your `urls.py` that uses `RevProxy.as_view()` to point to an `upstream` URL. This example proxies all requests to `/external/` to `https://www.example.com/`. Remember to set a proper `SECRET_KEY` in production.
# myproject/settings.py
import os
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'revproxy',
]
SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', 'your-insecure-dev-secret-key')
DEBUG = True
ALLOWED_HOSTS = []
ROOT_URLCONF = 'myproject.urls'
# For simplicity in quickstart, typically more settings would be here
# myproject/urls.py
from django.contrib import admin
from django.urls import path, re_path
from revproxy.views import RevProxy
urlpatterns = [
path('admin/', admin.site.urls),
# Proxy all requests under /external/ to example.com
# Access this at http://localhost:8000/external/
re_path(r'^external/(?P<path>.*)$', RevProxy.as_view(upstream='https://www.example.com/'))
]
Debug
Known issues
breakingOlder Django projects or examples from `django-revproxy` versions prior to 0.10.0 might use `django.conf.urls.url`. Django 2.0+ deprecated `url` in favor of `re_path` for regex-based URL patterns.fixAlways use `from django.urls import re_path` and `re_path(...)` for your regex-based proxy URL patterns.
affects: < 0.10.0 (or Django < 2.0)
gotchaThe default `REVPROXY_HISTORY_STORAGE_BACKEND` is in-memory (`revproxy.history.MemoryHistoryStorage`), which is not suitable for production environments with multiple processes or server restarts as it loses state.fixFor production, configure `REVPROXY_HISTORY_STORAGE_BACKEND` in `settings.py` to use a persistent storage like `django.contrib.sessions.backends.db` or a custom database-backed solution. Example: `REVPROXY_HISTORY_STORAGE_BACKEND = 'django.contrib.sessions.backends.db'`
affects: All versions
gotchaProxying external services, especially with user-controlled `upstream` URLs or broad header forwarding, can introduce security vulnerabilities (e.g., SSRF, header injection, information leakage).fixCarefully validate and sanitize any user-provided `upstream` URLs. Explicitly whitelist allowed headers to forward using `REVPROXY_WHITELIST_TABLE_HEADERS` and control cookie forwarding to prevent unintended information disclosure or session conflicts.
affects: All versions
gotchaStatic assets (CSS, JS, images) from the proxied site might not load correctly if they use relative URLs and the proxy path doesn't align with the original site structure, or if `django-revproxy` isn't configured to rewrite them.fixIf assets are not loading, try setting `REVPROXY_FORCE_REWRITE = True` in your `settings.py` to force `django-revproxy` to rewrite URLs in the proxied content. Ensure your `upstream` URL correctly points to the base of the external site.
affects: All versions
Upgrade
Version history
0.13.0latest on PyPI · released Nov 6, 2024
Audit
Dependencies
DjangorequiredCore framework dependency for the application.