Я использую mod_xsendfile (v0.12) для обслуживания статических файлов, где Django контролирует доступ к файлам на основе пользователей и разрешений.
В моем файле conf у меня есть:
XSendFile On
XSendFilePath e:/documents/
<Directory e:/Documents>
Order allow,deny
Allow from all
</Directory>
В моем коде django я установил заголовки так:
assert(isinstance(filename, FieldFile))
xsendfile = filename.name
if(platform.system() == 'Windows'):
xsendfile = xsendfile.replace('\\', '/')
response = HttpResponse()
response['X-Sendfile'] = xsendfile
mimetype = mimetypes.guess_type(xsendfile)[0]
response['Content-Type'] = mimetype
response['Content-Length'] = filename.size
И в моем лог-файле я получаю:
[Fri Oct 22 08:54:22 2010] [error] [client 192.168.20.34] (20023)The given path
was above the root path: xsendfile: unable to find file:
e:/Documents/3/2010-10-20/TestDocument.pdf
В этой версии mod_xsendfile
,
XSendFileAllowAbove On
генерирует ошибку:
Invalid command 'XSendFileAllowAbove', perhaps misspelled or defined by a module
not included in the server configuration
Я предположил, что это потому, что они добавили белый список XSendFilePath
. Кто-нибудь еще заставил это работать?