Asp.net core Ubuntu 16.04上的ASP.Net内核给了我一个糟糕的网关

Asp.net core Ubuntu 16.04上的ASP.Net内核给了我一个糟糕的网关,asp.net-core,.net-core,ubuntu-16.04,Asp.net Core,.net Core,Ubuntu 16.04,我读了斯科特·汉斯曼的精彩文章 我启动了主管,但当我浏览到我的网站时,我只得到了一个502坏网关 有什么想法吗 anton@ubuntu-512mb-lon1-01:/var/dotnettest$ sudo tail -f /var/log/dotnettest.out.log 现在收听: 应用程序已启动。按Ctrl+C组合键关闭。 警告:Microsoft.Extensions.DependencyInjection.DataProtectionServices[59] 用户配置文件和HK

我读了斯科特·汉斯曼的精彩文章

我启动了主管,但当我浏览到我的网站时,我只得到了一个502坏网关

有什么想法吗

anton@ubuntu-512mb-lon1-01:/var/dotnettest$ sudo tail -f /var/log/dotnettest.out.log
现在收听: 应用程序已启动。按Ctrl+C组合键关闭。 警告:Microsoft.Extensions.DependencyInjection.DataProtectionServices[59] 用户配置文件和HKLM注册表均不可用。使用临时密钥存储库。应用程序退出时,受保护的数据将不可用。 警告:Microsoft.AspNetCore.DataProtection.Repositories.EphemeralXmlRepository[50] 使用内存存储库。密钥将不会持久化到存储。 托管环境:生产 内容根路径:/var/dotnetest 现在收听:


让它工作,希望它能帮助其他人。。。4张Ubuntu图片(稍后…:)

坏网关是由于Kestrel服务器与您使用的Nginx侦听端口不在同一端口上服务而导致的

首先,确保在Program.Main中添加了.UserConfiguration(config)

public static void Main(string[] args)
{
    var config = new ConfigurationBuilder()
        .SetBasePath(Directory.GetCurrentDirectory())
        .AddJsonFile("hosting.json", optional: true)
        .Build();

    var host = new WebHostBuilder()
        .UseKestrel()
        .UseConfiguration(config) //MAKE SURE THIS IS IN
        .UseContentRoot(Directory.GetCurrentDirectory())
        .UseStartup<Startup>()
        .Build();

    host.Run();
}
publicstaticvoidmain(字符串[]args)
{
var config=new ConfigurationBuilder()
.SetBasePath(目录.GetCurrentDirectory())
.AddJsonFile(“hosting.json”,可选:true)
.Build();
var host=new WebHostBuilder()
.UseKestrel()
.UseConfiguration(config)//请确保该文件处于
.UseContentRoot(目录.GetCurrentDirectory())
.UseStartup()
.Build();
host.Run();
}
另外,请确保使用Microsoft.Extensions.Configuration添加了;指向Program.cs的命名空间

然后根据Scott的帖子将hosting.js文件添加到路由中

如果您现在运行dotnet,请确保应用程序在您根据Scott post在hosting.js文件中指定的端口上启动:5123

发布应用程序并执行主管停止和启动后,通过运行此命令确保端口为5123

sudo tail-f/var/log/dotnetest.out.log

这必须是端口5123,而不是默认的5000,如果是,那么您在发布的目录中缺少hosting.js文件,如果您遵循post,它将是/var/dotnetest

我做的另一件非常愚蠢的事是,我在testapp下发布了我的应用程序,而supervisor conf正在寻找dotnettest.dll,而不是testapp.dll,这将给你一个可爱的

nginx主管被SIGABRT终止;不期而至

错误

多亏了Scott Hanselman没有这些人我们该怎么办。。。


干杯

让它工作起来,希望它能帮助其他人。。。4张Ubuntu图片(稍后…:)

坏网关是由于Kestrel服务器与您使用的Nginx侦听端口不在同一端口上服务而导致的

首先,确保在Program.Main中添加了.UserConfiguration(config)

public static void Main(string[] args)
{
    var config = new ConfigurationBuilder()
        .SetBasePath(Directory.GetCurrentDirectory())
        .AddJsonFile("hosting.json", optional: true)
        .Build();

    var host = new WebHostBuilder()
        .UseKestrel()
        .UseConfiguration(config) //MAKE SURE THIS IS IN
        .UseContentRoot(Directory.GetCurrentDirectory())
        .UseStartup<Startup>()
        .Build();

    host.Run();
}
publicstaticvoidmain(字符串[]args)
{
var config=new ConfigurationBuilder()
.SetBasePath(目录.GetCurrentDirectory())
.AddJsonFile(“hosting.json”,可选:true)
.Build();
var host=new WebHostBuilder()
.UseKestrel()
.UseConfiguration(config)//请确保该文件处于
.UseContentRoot(目录.GetCurrentDirectory())
.UseStartup()
.Build();
host.Run();
}
另外,请确保使用Microsoft.Extensions.Configuration添加了;指向Program.cs的命名空间

然后根据Scott的帖子将hosting.js文件添加到路由中

如果您现在运行dotnet,请确保应用程序在您根据Scott post在hosting.js文件中指定的端口上启动:5123

发布应用程序并执行主管停止和启动后,通过运行此命令确保端口为5123

sudo tail-f/var/log/dotnetest.out.log

这必须是端口5123,而不是默认的5000,如果是,那么您在发布的目录中缺少hosting.js文件,如果您遵循post,它将是/var/dotnetest

我做的另一件非常愚蠢的事是,我在testapp下发布了我的应用程序,而supervisor conf正在寻找dotnettest.dll,而不是testapp.dll,这将给你一个可爱的

nginx主管被SIGABRT终止;不期而至

错误

多亏了Scott Hanselman没有这些人我们该怎么办。。。


干杯

如果安东的话仍然无效,那么可能值得检查
Startup.Configure()
是否正在使用
app.UseHttpsRedirection()
hosting.json
/参数和Nginx设置没有为此做好准备

在我的例子中,从一开始我就尝试设置SSL,因为我使用的VisualStudio模板在默认情况下启用了它(带Angular的SPA),但过了一段时间,它变得太难了,决定以后再使用它。。。只是忘了删除行表单
Startup.cs
,这导致应用程序在失败时反复重启


我通过查看带有
sudo tail-f/var/log/myapp.err.log
(或在supervisor的配置文件中设置的任何文件名)的错误日志发现,如果Anton的评论仍然不起作用,那么可能值得检查
Startup.Configure()
是否正在使用
app.usehttpseredirection()
hosting.json
/参数和Nginx设置没有为此做好准备

在我的例子中,从一开始我就尝试设置SSL,因为我使用的VisualStudio模板在默认情况下启用了它(带Angular的SPA),但过了一段时间,它变得太难了,决定以后再使用它。。。只是忘了删除行表单
Startup.cs
,这导致应用程序在失败时反复重启

我通过使用sudotail-f/var/log/myapp.err.log查看错误日志(或者在supervisor的配置文件中设置的任何文件名)发现了这一点