私は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
ホワイトリストを追加したからだと思いました。他の誰かがこれを機能させましたか?