1👍
The problem was with path. Solution was here:
Convert an IRI path to URI before setting as NGINX header
NGINX does not support non-ASCII characters in the header, so we need
convert the IRI path to URI so it’s compatible with what NGINX expects
as the header value.
Final code for views:
from django.utils.encoding import iri_to_uri
@login_required
def protected_serve(request, path):
x_accel_redirect = iri_to_uri(path)
response = HttpResponse()
response['Content-Type']=""
response['X-Accel-Redirect'] = '/protected_media/' + x_accel_redirect
return response
Source:stackexchange.com