From 67dc2d5b4e3ad716cd349a58fdbabe550abf557c Mon Sep 17 00:00:00 2001 From: zhangqi <2794379662@qq.com> Date: Thu, 25 Feb 2021 16:00:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=8D=E5=90=91=E4=BB=A3?= =?UTF-8?q?=E7=90=86=E4=B8=AD=E9=97=B4=E4=BB=B6=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- QRCodeService/Startup.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/QRCodeService/Startup.cs b/QRCodeService/Startup.cs index ecc6f47..03e8c55 100644 --- a/QRCodeService/Startup.cs +++ b/QRCodeService/Startup.cs @@ -7,6 +7,7 @@ using Infrastructure.Repositories; using MediatR; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.Redis; @@ -78,6 +79,12 @@ namespace QRCodeService //redis cache services.AddDistributedRedisCache(options=>options.Configuration=Configuration.GetSection("redis:default").Value); + //反向代理中间件 + services.Configure(options => + { + options.ForwardedHeaders = + ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; + }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -89,6 +96,7 @@ namespace QRCodeService app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "QRCodeService v1")); } + app.UseForwardedHeaders(); app.UseRouting();