Apache와 Pinax는 인증 된 사용자에게만 첨부 파일을 제공하기를 원합니다.Pinax 및 Apache : 인증 된 사용자에게만 첨부 파일을 전달하십시오.
이 post을 찾았지만 제대로 작동하지 않습니다.
내 아파치의 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을 상관없이 발생 사용자가 로그인되어있는 경우
배포 서버를 통해 뷰에 액세스 할 수 있지만 데이터가 전송되지 않습니다.
무엇이 잘못 되었나요?
내가 내 생산을 요구하고있다 서버 설정. dev 서버를 실행할 때 뷰가 호출된다는 것은 URL이 올바른지 증명하는 것입니다. – vikingosegundo
아파치 설정을 실행하는 데 도움이 될 수 있습니다. http://serverfault.com/questions/59791/configure-apache-to-handle-a-sub-path-using-wsgi –