我希望Apache和Pinax仅向经过身份验证的用户传递附件。Pinax&Apache:仅向经过验证的用户传递附件
我发现这个post,但我不能让它工作。
我的Apache-conf的文件:
WSGIPythonPath /usr/local/bin/python
<VirtualHost *:80>
ServerName www.domain.com
ServerAlias domain.com
WSGIDaemonProcess k-production python-path=/path/to/app/pinax-env/lib/python2.6/site-packages
WSGIProcessGroup k-production
Alias /site_media /path/to/app/cp/site_media
<Directory /path/to/app/cp/site_media>
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias /site_media/media/attachments /path/to/app/cp/deploy/pinax.wsgi
<Directory /path/to/app/cp/site_media/media/attachments>
Deny from all
</Directory>
XSendFile On
XSendFileAllowAbove On
WSGIScriptAlias//path/to/app/cp/deploy/pinax.wsgi
<Directory /path/to/app/cp/deploy>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
和我(仍然粗糙)认为,这应该被调用:
@login_required
def sendfile(request, slug):
app, content_object_id, img = slug.split('/')
project_file = get_object_or_404(Attachment, attachment_file = 'attachments/'+slug)
response = HttpResponse()
response['X-Sendfile'] = os.path.join(settings.MEDIA_ROOT, 'attachments/'+slug)
content_type = 'application/octet-stream'
response['Content-Type'] = content_type
response['Content-Disposition'] = 'attachment; filename="%s"' % os.path.basename(os.path.join(settings.MEDIA_ROOT, 'attachments/'+slug))
return response
阿帕奇抛出一个403无论用户是否登录
通过开发服务器我可以访问视图,但没有数据会被传输。
出了什么问题?
我要求我的生产服务器设置。在运行开发服务器时调用视图只能证明url是正确的。 – vikingosegundo 2009-11-26 15:50:36
这可能会有所帮助,让您的Apache安装程序运行: http://serverfault.com/questions/59791/configure-apache-to-handle-a-sub-path-using-wsgi – 2009-11-27 13:56:09