
前提
.NET6 + Nginx+ Linux(さくらVPS)でWEBサービスを1年ほど運用しています。
先日SSL証明書の更新を行いました。
最終的にNginxの再起動を行い、ブラウザの証明書ビューアから有効期限が更新されていること確認できました。
後日、.NET6のアプリケーションを修正したのでいつものように更新を行い、サービスを起動しましたが、起動失敗しており、ブラウザで確認すると502エラーが発生いているとNginxが返してきました。
質問
エラーメッセージについて、調査方法・考えられる原因など、なんでもいいので皆さんからアドバイス頂けたらありがたいです。
些細な情報、誤情報でも構いません。
発生している問題・エラーメッセージ
.NETのアプリ起動ログを確認したところ以下のエラーが発生していました。
Unhandled exception. System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date. To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'. For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054. at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action`1 configureOptions) at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IEnumerable`1 listenOptions, AddressBindContext context, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken) at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken) at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host) at orgsys.Program.Main(String[] args) in /home/userA/gitwork/orgsys/orgsys/Program.cs:line 16
試したこと
翻訳すると以下の内容ですが、証明書更新したはずなので、調査に行き詰っております。
HTTPS エンドポイントを構成できません。 サーバー証明書が指定されていません。 デフォルトの開発者証明書が見つからないか、期限が切れています。
補足情報(FW/ツールのバージョンなど)
Program.cs
public class Program { public static void Main(string[] args) { CreateHostBuilder(args).Build().Run(); //★エラー発生のline 16はここです。 } public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); }); }
Startup.cs
public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } public void ConfigureServices(IServiceCollection services) { services.AddHeadElementHelper(); services.AddDbContextFactory<ApplicationDbContext>( dbContextOptions => dbContextOptions .UseMySql(Configuration.GetConnectionString("DefaultConnection"), new MySqlServerVersion(new Version())) .EnableSensitiveDataLogging(true) .EnableDetailedErrors(true)); services.AddDbContextPool<ApplicationDbContext>( dbContextOptions => dbContextOptions .UseMySql(Configuration.GetConnectionString("DefaultConnection"), new MySqlServerVersion(new Version())) .EnableSensitiveDataLogging(true) .EnableDetailedErrors(true) ); services.AddRazorPages(); services.AddServerSideBlazor(); services.AddScoped<AuthenticationStateProvider, RevalidatingIdentityAuthenticationStateProvider<ApplicationUser>>(); services.AddDatabaseDeveloperPageExceptionFilter(); services.AddHttpClient(); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseMigrationsEndPoint(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHeadElementServerPrerendering(); //app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); } }
Nginxのerror.logは以下の通りです。
そもそもservice立ち上がってないのでそこにアクセスできていないだけなので情報価値はあまりないかもしれません。
2023/01/27 21:14:24 [error] 4053259#0: *6689 connect() failed (111: Connection refused) while connecting to upstream, client: XXX.XXX.XXX.XX, server: XXXXXXXX.jp, request: "GET /admin/ HTTP/1.1", upstream: "http://127.0.0.1:5000/admin/", host: "XXX.XXX.XXX.XX"
ご協力何卒よろしくお願いいたします。




回答1件
あなたの回答
tips
プレビュー