Add `NGINX_X_ACCEL_REDIRECT` setting. Check this instead of `DEBUG` when deciding to use the `X-Accel-Redirect` header.

rtd2
Tai Lee 2013-03-28 12:56:11 +11:00
parent 9751da0754
commit 736847a4d8
2 changed files with 8 additions and 1 deletions

View File

@ -69,3 +69,10 @@ USE_PIP_INSTALL
Default: `False`
Whether to use `pip install .` or `python setup.py install` when installing packages into the Virtualenv. Default is to use pip.
NGINX_X_ACCEL_REDIRECT
----------------------
Default: `False`
Enable this if you are using Nginx for improved file handling.

View File

@ -306,7 +306,7 @@ def serve_docs(request, lang_slug, version_slug, filename, project_slug=None):
basepath = proj.translations_path(lang_slug)
basepath = os.path.join(basepath, version_slug)
log.info('Serving %s for %s' % (filename, proj))
if not settings.DEBUG:
if getattr(settings, 'NGINX_X_ACCEL_REDIRECT', False):
fullpath = os.path.join(basepath, filename)
mimetype, encoding = mimetypes.guess_type(fullpath)
mimetype = mimetype or 'application/octet-stream'