添加反向代理中间件配置
This commit is contained in:
@@ -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<ForwardedHeadersOptions>(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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user