通过django控制权限,nginx返回静态文件

nginx配置:
server {
            listen 8080;
            server_name 0.0.0.0;

            location /app01/ {
                proxy_pass http://127.0.0.1:8000;
            }
            location /download/ {
                internal;
                alias /home/rainbow/download/;  # 存放静态文件的目录
            }
        }


django视图函数:
        response = HttpResponse()
        response['Content-Type'] = 'application/octet-stream'
        response['Content-Disposition'] = 'attachment;filename=link.txt'  # {filename}
        response['X-Accel-Redirect'] = '/download/tplink/link.txt'  # /download/{filepath}/{filename}
        return response


django中做权限控制,nginx来返回文件,用户无法获取到真实文件存放地址

你可能感兴趣的:(通过django控制权限,nginx返回静态文件)