ASP.Net Ubuntu 16.04 上的核心给我错误的网关
ASP.Net Core on Ubuntu 16.04 gives me Bad Gateway
我关注了 Scott Hanselman 的精彩文章 http://www.hanselman.com/blog/PublishingAnASPNETCoreWebsiteToACheapLinuxVMHost.aspx
我让主管启动了,但是当我浏览到我的 Digitial Ocean Droplet 时,我只得到一个 502 Bad Gateway。
有什么想法吗?
anton@ubuntu-512mb-lon1-01:/var/dotnettest$ sudo tail -f /var/log/dotnettest.out.log
正在收听:http://localhost:5000
申请开始。按 Ctrl+C 关闭。
警告:Microsoft.Extensions.DependencyInjection.DataProtectionServices[59]
用户配置文件和 HKLM 注册表均不可用。使用临时密钥存储库。当应用程序退出时,受保护的数据将不可用。
警告:Microsoft.AspNetCore.DataProtection.Repositories.EphemeralXmlRepository[50]
使用内存存储库。密钥不会持久存储。
托管环境:生产
内容根路径:/var/dotnettest
现在收听:http://localhost:5000
anton@ubuntu-512mb-lon1-01:/var/dotnettest$ sudo tail -f /var/log/supervisor/supervisord.log
> 2017-02-15 08:11:58,737 INFO waiting for dotnettest to die 2017-02-15
> 08:11:58,782 WARN received SIGTERM indicating exit request 2017-02-15
> 08:11:58,815 INFO stopped: dotnettest (exit status 0) 2017-02-15
> 08:12:09,996 CRIT Supervisor running as root (no user in config file)
> 2017-02-15 08:12:09,996 WARN Included extra file
> "/etc/supervisor/conf.d/dotnettest.conf" during parsing 2017-02-15
> 08:12:10,006 INFO RPC interface 'supervisor' initialized 2017-02-15
> 08:12:10,007 CRIT Server 'unix_http_server' running without any HTTP
> authentication checking 2017-02-15 08:12:10,007 INFO supervisord
> started with pid 13383 2017-02-15 08:12:11,011 INFO spawned:
> 'dotnettest' with pid 13388 2017-02-15 08:12:12,013 INFO success:
> dotnettest entered RUNNING state, process has stayed up for > than 1
> seconds (startsecs)
成功了,希望它对其他人有帮助...稍后 4 x 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();
}
还要确保你添加了 using Microsoft.Extensions.Configuration; Program.cs
的命名空间
然后根据 Scott 的 post.
将您的 hosting.js 文件添加到路线
如果你现在做一个 dotnet 运行 确保应用程序在你在 hosting.js 文件中指定的端口上启动,根据 Scott post 它将是:5123
在您发布应用程序并执行主管停止和启动后,通过 运行 宁此
确保端口为 5123
sudo tail -f /var/log/dotnettest.out.log
这必须是端口 5123 而不是默认的 5000,如果它是那么你在发布的目录中缺少 hosting.js 文件,如果你遵循 post 它将是 /var/dotnettest
我做的另一件真正愚蠢的事情是我在 testapp 下发布了我的应用程序,而主管 conf 正在寻找 dotnettest.dll 而不是 testapp.dll 这会给你一个可爱的
nginx supervisor terminated by SIGABRT; not expected
错误
多亏了 Scott Hanselman,没有这些人会怎样...
http://www.hanselman.com/blog/PublishingAnASPNETCoreWebsiteToACheapLinuxVMHost.aspx
干杯
如果 Anton 的评论仍然无效,可能值得检查一下 Startup.Configure()
是否正在使用 app.UseHttpsRedirection();
而 hosting.json
/arguments 和 Nginx 设置没有为此做好准备。
就我而言,从一开始我就尝试设置 SSL,因为我使用的 Visual Studio 模板默认启用了它(带有 [=24 的 SPA =]),但过了一会儿它变得太难了,决定留待以后使用...只是忘记删除该行形式 Startup.cs
,这导致应用程序在失败时反复重生。
我通过使用 sudo tail -f /var/log/myapp.err.log
(或您在主管的配置文件中设置的任何文件名)查看错误日志发现了这一点
我关注了 Scott Hanselman 的精彩文章 http://www.hanselman.com/blog/PublishingAnASPNETCoreWebsiteToACheapLinuxVMHost.aspx
我让主管启动了,但是当我浏览到我的 Digitial Ocean Droplet 时,我只得到一个 502 Bad Gateway。
有什么想法吗?
anton@ubuntu-512mb-lon1-01:/var/dotnettest$ sudo tail -f /var/log/dotnettest.out.log
正在收听:http://localhost:5000 申请开始。按 Ctrl+C 关闭。 警告:Microsoft.Extensions.DependencyInjection.DataProtectionServices[59] 用户配置文件和 HKLM 注册表均不可用。使用临时密钥存储库。当应用程序退出时,受保护的数据将不可用。 警告:Microsoft.AspNetCore.DataProtection.Repositories.EphemeralXmlRepository[50] 使用内存存储库。密钥不会持久存储。 托管环境:生产 内容根路径:/var/dotnettest 现在收听:http://localhost:5000
anton@ubuntu-512mb-lon1-01:/var/dotnettest$ sudo tail -f /var/log/supervisor/supervisord.log
> 2017-02-15 08:11:58,737 INFO waiting for dotnettest to die 2017-02-15
> 08:11:58,782 WARN received SIGTERM indicating exit request 2017-02-15
> 08:11:58,815 INFO stopped: dotnettest (exit status 0) 2017-02-15
> 08:12:09,996 CRIT Supervisor running as root (no user in config file)
> 2017-02-15 08:12:09,996 WARN Included extra file
> "/etc/supervisor/conf.d/dotnettest.conf" during parsing 2017-02-15
> 08:12:10,006 INFO RPC interface 'supervisor' initialized 2017-02-15
> 08:12:10,007 CRIT Server 'unix_http_server' running without any HTTP
> authentication checking 2017-02-15 08:12:10,007 INFO supervisord
> started with pid 13383 2017-02-15 08:12:11,011 INFO spawned:
> 'dotnettest' with pid 13388 2017-02-15 08:12:12,013 INFO success:
> dotnettest entered RUNNING state, process has stayed up for > than 1
> seconds (startsecs)
成功了,希望它对其他人有帮助...稍后 4 x 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();
}
还要确保你添加了 using Microsoft.Extensions.Configuration; Program.cs
的命名空间然后根据 Scott 的 post.
将您的 hosting.js 文件添加到路线如果你现在做一个 dotnet 运行 确保应用程序在你在 hosting.js 文件中指定的端口上启动,根据 Scott post 它将是:5123
在您发布应用程序并执行主管停止和启动后,通过 运行 宁此
确保端口为 5123sudo tail -f /var/log/dotnettest.out.log
这必须是端口 5123 而不是默认的 5000,如果它是那么你在发布的目录中缺少 hosting.js 文件,如果你遵循 post 它将是 /var/dotnettest
我做的另一件真正愚蠢的事情是我在 testapp 下发布了我的应用程序,而主管 conf 正在寻找 dotnettest.dll 而不是 testapp.dll 这会给你一个可爱的
nginx supervisor terminated by SIGABRT; not expected
错误
多亏了 Scott Hanselman,没有这些人会怎样... http://www.hanselman.com/blog/PublishingAnASPNETCoreWebsiteToACheapLinuxVMHost.aspx
干杯
如果 Anton 的评论仍然无效,可能值得检查一下 Startup.Configure()
是否正在使用 app.UseHttpsRedirection();
而 hosting.json
/arguments 和 Nginx 设置没有为此做好准备。
就我而言,从一开始我就尝试设置 SSL,因为我使用的 Visual Studio 模板默认启用了它(带有 [=24 的 SPA =]),但过了一会儿它变得太难了,决定留待以后使用...只是忘记删除该行形式 Startup.cs
,这导致应用程序在失败时反复重生。
我通过使用 sudo tail -f /var/log/myapp.err.log
(或您在主管的配置文件中设置的任何文件名)查看错误日志发现了这一点