aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Startup.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-06-02 19:07:27 +0800
committercrupest <crupest@outlook.com>2020-06-02 19:07:27 +0800
commit3abd2446df84eeae99d27d0fc0b688702f5e77f8 (patch)
treec74ac2e3f7e124d132cb85fdc20c5632e1222852 /Timeline/Startup.cs
parent8473ce1e9f3495630f7382957a5a1cfb567e95ea (diff)
downloadtimeline-3abd2446df84eeae99d27d0fc0b688702f5e77f8.tar.gz
timeline-3abd2446df84eeae99d27d0fc0b688702f5e77f8.tar.bz2
timeline-3abd2446df84eeae99d27d0fc0b688702f5e77f8.zip
fix: not recognize forwarded https protocal.
Diffstat (limited to 'Timeline/Startup.cs')
-rw-r--r--Timeline/Startup.cs16
1 files changed, 13 insertions, 3 deletions
diff --git a/Timeline/Startup.cs b/Timeline/Startup.cs
index 09281551..5dbc99e6 100644
--- a/Timeline/Startup.cs
+++ b/Timeline/Startup.cs
@@ -97,10 +97,20 @@ namespace Timeline
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app)
{
- app.UseForwardedHeaders(new ForwardedHeadersOptions
+ if (string.Equals(System.Environment.GetEnvironmentVariable("ASPNETCORE_FORWARDEDHEADERS_ENABLED"), "true", StringComparison.OrdinalIgnoreCase))
{
- ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
- });
+ var options = new ForwardedHeadersOptions
+ {
+ ForwardedHeaders = ForwardedHeaders.XForwardedFor |
+ ForwardedHeaders.XForwardedProto
+ };
+ // Only loopback proxies are allowed by default.
+ // Clear that restriction because forwarders are enabled by explicit
+ // configuration.
+ options.KnownNetworks.Clear();
+ options.KnownProxies.Clear();
+ app.UseForwardedHeaders(options);
+ }
app.UseRouting();