通过Nginx代理设置下载文件

时间:2019-05-10 11:10:09

标签: c# .net nginx asp.net-core

.net core 2.2下的Ubuntu 18.04服务器启动了一个网站。文件正常上传到站点,但是下载时发生404错误。

Nginx配置:

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    server_name _;

    location / {
        proxy_pass         http://localhost:5000;
            proxy_http_version 1.1;
            proxy_set_header   Upgrade $http_upgrade;
            proxy_set_header   Connection keep-alive;
            proxy_set_header   Host $host;
            proxy_cache_bypass $http_upgrade;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Proto $scheme;
        #try_files $uri $uri/ =404;
    }
}

文件生成并通过以下代码发送:

public FileResult Download(int id)
{
    byte[] fileBytes = null;
    string fileName = "";
    //getting file data and name
    return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);
}

请告诉我,出什么问题了

0 个答案:

没有答案
相关问题