From 3dc826f5f581a4a92e1ccc268b872f3868965b3c Mon Sep 17 00:00:00 2001 From: Gregory Rudolph Date: Wed, 25 Aug 2021 20:34:56 -0400 Subject: [PATCH] Runtime changes --- Pages/Index.cshtml.cs | 2 +- Startup.cs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Pages/Index.cshtml.cs b/Pages/Index.cshtml.cs index 36dd62d..4b592ca 100644 --- a/Pages/Index.cshtml.cs +++ b/Pages/Index.cshtml.cs @@ -8,7 +8,7 @@ namespace NightmareCoreWeb2.Pages { public class IndexModel : PageModel { - string connStr = $"server={Program.MysqlServer};user={Program.MysqlUser};database={Program.MysqlDatabase};port={Program.MysqlPort};password={Program.MysqlPassword}"; + string connStr = $"SslMode=None;server={Program.MysqlServer};user={Program.MysqlUser};database={Program.MysqlDatabase};port={Program.MysqlPort};password={Program.MysqlPassword}"; public List OnlineCharacters = new List(); public Dictionary Realms = new Dictionary(); diff --git a/Startup.cs b/Startup.cs index 45b1ab3..1a00c47 100644 --- a/Startup.cs +++ b/Startup.cs @@ -2,9 +2,11 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using System.Net; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.HttpsPolicy; +using Microsoft.AspNetCore.HttpOverrides; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -24,6 +26,12 @@ namespace NightmareCoreWeb2 public void ConfigureServices(IServiceCollection services) { services.AddRazorPages(); + services.Configure(options => + { + options.KnownProxies.Add(IPAddress.Parse("192.168.1.102")); + options.ForwardedHeaders = + ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; + }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -32,10 +40,12 @@ namespace NightmareCoreWeb2 if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); + app.UseForwardedHeaders(); } else { app.UseExceptionHandler("/Error"); + app.UseForwardedHeaders(); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); }