{"id":44769,"library":"django-xff","title":"django-xff","description":"Middleware and utilities for handling X-Forwarded-For and related proxy headers in Django. Version 1.5.0 is current; releases are infrequent.","status":"active","version":"1.5.0","language":"python","source_language":"en","source_url":"https://github.com/ferrix/xff/","tags":["django","middleware","proxy","xff","x-forwarded-for"],"install":[{"cmd":"pip install django-xff","lang":"bash","label":"Default install"}],"dependencies":[{"reason":"Runtime dependency; requires Django >= 2.0? Not enforced via requires_python but tested against Django 2.2+.","package":"django","optional":false}],"imports":[{"note":"Old import path caused ImportError starting in 1.0.0.","wrong":"from xff import XForwardedForMiddleware","symbol":"XForwardedForMiddleware","correct":"from xff.middleware import XForwardedForMiddleware"}],"quickstart":{"code":"MIDDLEWARE = [\n    'xff.middleware.XForwardedForMiddleware',\n    # ... other middleware\n]\n\n# settings.py\nXFF_USE_PROXY = True  # required if behind a trusted proxy","lang":"python","description":"Add the middleware to INSTALLED_APPS (auto-discovered) or MIDDLEWARE. Set XFF_USE_PROXY = True when behind a trusted proxy to rewrite REMOTE_ADDR."},"warnings":[{"fix":"Use 'from xff.middleware import XForwardedForMiddleware' or the dotted string 'xff.middleware.XForwardedForMiddleware' in MIDDLEWARE.","message":"In version 1.0.0, the import path changed from 'xff.XForwardedForMiddleware' to 'xff.middleware.XForwardedForMiddleware'.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Set XFF_USE_PROXY = True in Django settings.","message":"The middleware automatically rewrites request.META['REMOTE_ADDR'] only if XFF_USE_PROXY = True is set. Without it, the middleware does nothing.","severity":"gotcha","affected_versions":"all"},{"fix":"Manually validate or use a custom middleware if you need strict proxy chain validation.","message":"The middleware does not validate the number of proxies or perform any IP whitelisting by default. It trusts the leftmost IP in the X-Forwarded-For header blindly when XFF_USE_PROXY is True.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'1.5.0':20 'current':22 'django':2,18,26 'django-xff':1 'forward':11,32 'handl':8 'header':16 'infrequ':25 'middlewar':4,27 'proxi':15,28 'relat':14 'releas':23 'util':6 'version':19 'x':10,31 'x-forwarded-for':9,30 'xff':3,29","created_at":"2026-06-07T12:51:45.230025+00:00","updated_at":"2026-06-07T12:51:45.230025+00:00","problems":[{"fix":"Run 'pip install django-xff'.","cause":"Package not installed or virtual environment not activated.","error":"ModuleNotFoundError: No module named 'xff'"},{"fix":"Change to 'from xff.middleware import XForwardedForMiddleware'.","cause":"Import path changed in version 1.0.0; using old 'from xff import XForwardedForMiddleware'.","error":"ImportError: cannot import name 'XForwardedForMiddleware' from 'xff'"},{"fix":"Ensure the middleware is only used with WSGI/ASGI HTTP requests.","cause":"The middleware is applied to a non-HTTP request (e.g., test client or async).","error":"AttributeError: 'WSGIRequest' object has no attribute 'META'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/ferrix/xff/","github":"https://github.com/ferrix/xff/","docs":null,"changelog":null,"pypi":null,"npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["security","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}