如何将所有请求从nginx转发到.net core应用程序

问题描述 投票:0回答:1

我已使用 nginx 将我的 .net core Web 应用程序部署到 Ubuntu 16.04 Server,并且我想将所有传入请求发送到我的 .net core 应用程序。

我已经使用了教程这里。我的

sites-available/default
文件如下:

server {
listen 80;

server_name example.com *.example.com;

location / {
    proxy_pass         http://localhost:5000;
    proxy_redirect     off;
        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;   
}   

一切工作正常,除了一个操作 - 当我想传递参数来动态更改图像大小时:

http://example.com/api/files/get/5beffcb65a8e8f1c700a1a22/image?w=400&h=400

在这种情况下我会收到 404 错误。 Nginx 返回该错误。我通过curl在本地测试了它并对我的.net core应用程序执行直接请求,它工作正常。

那么如何配置 nginx 将所有带有所有参数的请求发送到我的 .net core 应用程序?

nginx asp.net-core .net-core ubuntu-16.04
1个回答
0
投票

请勿将代理重定向设置为关闭。请参阅此链接了解解释:

https://unix.stackexchange.com/questions/290141/nginx-reverse-proxy-redirection

© www.soinside.com 2019 - 2024. All rights reserved.