I am building a music player application with Django + nginx for which I need a backend which supports byte range requests.
Django is authenticating the media file correctly but django dev server does not support range requests (206 partial response). Nginx directly serves byte range requests after using this configuration, I verified that the response header has content range. However I am unable to forward the request from django to nginx, to serve the content.
I tried using X-Accel-Redirect in a django view but still the response header doesn't have content range the way it would have been if the file had been directly served by nginx.
So I am trying to find a way to authenticate using Django and provide support for byte range requests with nginx or another static file server.
response = HttpResponse(content_type = mimetype, status=206)
response['Content-Disposition'] = "attachment; filename=%s" % \
(fileModel.FileName)
response['Accept-Ranges'] = 'bytes'
response['X-Accel-Redirect'] = settings.MEDIA_URL + '/' + fileModel.FileData.MD5
response['X-Accel-Buffering'] = 'no'
return response
This worked out for me. Now authentication with django + streaming with nginx is accomplished.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With