Ubuntu DotNet核心应用程序不';我不接受Linux上的POST

Ubuntu DotNet核心应用程序不';我不接受Linux上的POST,ubuntu,nginx,asp.net-core,asp.net-core-2.0,Ubuntu,Nginx,Asp.net Core,Asp.net Core 2.0,这是我的第一个DotNetCore 2.0应用程序,我想用它来比较IIS/Windows和nginx/Ubuntu的性能。这是一款与多个服务(mongo/redis/session state)对话的应用程序,可以创建一个虚假但真实的用户旅程 当从Visual Studio进行调试或从PostMan调用时,该应用程序在Windows上运行完全正常。但是,如果我部署到Ubuntu,尽管我可以访问站点的首页和下一页(都是GET),但只要我在第二页(仅一个字段)发布表单,它就会从浏览器和PostMan

这是我的第一个DotNetCore 2.0应用程序,我想用它来比较IIS/Windows和nginx/Ubuntu的性能。这是一款与多个服务(mongo/redis/session state)对话的应用程序,可以创建一个虚假但真实的用户旅程

当从Visual Studio进行调试或从PostMan调用时,该应用程序在Windows上运行完全正常。但是,如果我部署到Ubuntu,尽管我可以访问站点的首页和下一页(都是GET),但只要我在第二页(仅一个字段)发布表单,它就会从浏览器和PostMan上失败,但没有详细信息。Ubuntu除了启动web服务器之外,没有记录任何东西,尽管它以前记录过错误,所以日志记录工作正常

我甚至尝试了
IgnoreAntiforgeryToken
,但都没有用

相关配置:

public void ConfigureServices(IServiceCollection services)
{
    if (Configuration.GetValue<bool>("useFileSystem"))
    {
        services.AddDataProtection()
            .PersistKeysToFileSystem(new DirectoryInfo(Configuration.GetValue<string>("fileSystemPersistPath")))
            .SetApplicationName("Perftest2018");
    }
    else
    {
        services.AddDataProtection()
            .SetApplicationName("Perftest2018");
    }

    services.AddMvc();
    services.AddDistributedMemoryCache();
    services.AddSession(options =>
    {
        options.IdleTimeout = TimeSpan.FromSeconds(30);
        options.Cookie.HttpOnly = true;
    });

    services.Configure<IISOptions>(options =>
    {
        options.AutomaticAuthentication = false;
    });

    //<snip> the rest of my services
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    app.UseDeveloperExceptionPage();
    app.UseStaticFiles();
    app.UseSession();

    app.UseForwardedHeaders(new ForwardedHeadersOptions
    {
        ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
    });

    app.UseMvc(routes =>
    {
        routes.MapRoute(name: "default",template: "{controller=Home}/{action=Index}/{id?}");
    });
}
public void配置服务(IServiceCollection服务)
{
if(Configuration.GetValue(“useFileSystem”))
{
services.AddDataProtection()
.PersistKeyStoreFileSystem(新的DirectoryInfo(Configuration.GetValue(“FileSystemTempersistPath”))
.SetApplicationName(“Perftest2018”);
}
其他的
{
services.AddDataProtection()
.SetApplicationName(“Perftest2018”);
}
services.AddMvc();
AddDistributedMemoryCache();
services.AddSession(选项=>
{
options.IdleTimeout=TimeSpan.FromSeconds(30);
options.Cookie.HttpOnly=true;
});
配置(选项=>
{
options.AutomaticAuthentication=false;
});
//我其余的服务
}
公共无效配置(IApplicationBuilder应用程序,IHostingEnvironment环境)
{
app.UseDeveloperExceptionPage();
app.UseStaticFiles();
app.UseSession();
app.UseForwardedHeaders(新ForwardedHeaders选项
{
ForwardedHeaders=ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
app.UseMvc(路由=>
{
MapRoute(名称:“默认”,模板:“{controller=Home}/{action=Index}/{id?}”);
});
}
行动是这样的:

[HttpPost]
public async Task<IActionResult> Authorize(AuthorizeViewModel model)
{
    // The view model just has a single string property with no other attributes
}
[HttpPost]
公共异步任务授权(AuthorizeViewModel)
{
//视图模型只有一个字符串属性,没有其他属性
}

这是由于代理中的其他nginx头从另一台运行TLS的服务器获取的。标题
Upgrade$http\u Upgrade
连接“Upgrade”
可能不允许POST

400表示你的要求不好。你确定nginx不只是拒绝了它吗?因为当应用之前抛出时,它在我的错误日志中记录了错误?它是否会抛出并杀死日志输出?可能,但这并不能解释为什么它不起作用。nginx并没有拒绝它,它是dotnetcore的代理,其他页面也在工作。看看另一个问题,这可能与通过HTTP而不是HTTPS阻止POST有关吗?我可以看到如何启用此功能,但默认情况下它不会在任何地方启用。您是否缺少POST方法上的[FromBody]装饰程序?thx Lukos我也遇到了此问题,正如您所怀疑的,nginx在windows上运行良好,并且记录请求表明它从未向控制器发出过请求,这应该归咎于nginx。我猜这些额外的标题会导致kestrel出现问题-似乎只有当您打算使用WebSocket时才需要这些标题,请参阅阅读后的内容,似乎是
连接“升级”
导致了这些标题