{"id":9684,"library":"django-revproxy","title":"Django RevProxy","description":"Django RevProxy (version 0.13.0) is a Django application that provides a robust reverse proxy solution. It allows you to seamlessly proxy external websites or services through your Django application, handling URL rewriting, cookie management, and header forwarding. The library sees active, though irregular, development, with a focus on stability and compatibility with modern Django versions.","status":"active","version":"0.13.0","language":"en","source_language":"en","source_url":"https://github.com/dpipro/django-revproxy","tags":["django","reverse-proxy","proxy","web-server","http","middleware"],"install":[{"cmd":"pip install django-revproxy","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Core framework dependency for the application.","package":"Django","optional":false}],"imports":[{"symbol":"RevProxy","correct":"from revproxy.views import RevProxy"},{"symbol":"path","correct":"from django.urls import path"},{"symbol":"re_path","correct":"from django.urls import re_path"}],"quickstart":{"code":"# myproject/settings.py\nimport os\n\nINSTALLED_APPS = [\n    'django.contrib.admin',\n    'django.contrib.auth',\n    'django.contrib.contenttypes',\n    'django.contrib.sessions',\n    'django.contrib.messages',\n    'django.contrib.staticfiles',\n    'revproxy',\n]\n\nSECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', 'your-insecure-dev-secret-key')\nDEBUG = True\nALLOWED_HOSTS = []\n\nROOT_URLCONF = 'myproject.urls'\n\n# For simplicity in quickstart, typically more settings would be here\n\n# myproject/urls.py\nfrom django.contrib import admin\nfrom django.urls import path, re_path\nfrom revproxy.views import RevProxy\n\nurlpatterns = [\n    path('admin/', admin.site.urls),\n    # Proxy all requests under /external/ to example.com\n    # Access this at http://localhost:8000/external/\n    re_path(r'^external/(?P<path>.*)$', RevProxy.as_view(upstream='https://www.example.com/'))\n]","lang":"python","description":"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."},"warnings":[{"fix":"Always use `from django.urls import re_path` and `re_path(...)` for your regex-based proxy URL patterns.","message":"Older 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.","severity":"breaking","affected_versions":"< 0.10.0 (or Django < 2.0)"},{"fix":"For 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'`","message":"The 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Carefully 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.","message":"Proxying external services, especially with user-controlled `upstream` URLs or broad header forwarding, can introduce security vulnerabilities (e.g., SSRF, header injection, information leakage).","severity":"gotcha","affected_versions":"All versions"},{"fix":"If 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.","message":"Static 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Run `pip install django-revproxy` and ensure `'revproxy'` is added to your `INSTALLED_APPS` list in `settings.py`.","cause":"`django-revproxy` is either not installed or not included in `INSTALLED_APPS`.","error":"ModuleNotFoundError: No module named 'revproxy'"},{"fix":"Double-check the `upstream` URL for typos, correct scheme (`http://` or `https://`), and trailing slashes. Verify that your `re_path` regex (e.g., `r'^(?P<path>.*)$'`) correctly captures the path portion for the upstream target.","cause":"The `upstream` URL is incorrect, malformed, or the `re_path` regex pattern in `urls.py` does not correctly capture and forward the path to the proxy.","error":"Proxy returns 404 Not Found or an unexpected page/content from the upstream."},{"fix":"Use `REVPROXY_COOKIE_NAME_PREFIX = 'revproxy_'` (or another unique prefix) in your `settings.py` to namespace cookies forwarded by the proxy, preventing clashes. Review other cookie-related `REVPROXY_` settings if further customization is needed.","cause":"The default cookie handling might lead to conflicts between `django-revproxy`'s forwarded cookies and your primary Django application's cookies, or the upstream service expects specific cookie behaviors.","error":"Cookies or session data from the proxied site are not working or conflicting with the Django application's cookies."}]}