Reverse proxy 在IIS反向代理后面标识服务器4时,没有重定向回JsOidc客户端
在IIS反向代理之后,为什么IdentityServer4不重定向回JsOidc客户端,但其他客户端按预期工作 测试设置 DOW加载了IdentityServer 4.0-release 使用\Quickstarts\6\u AsNetIdentity在VS2017中进行设置测试 然后从\Clients\src\JsOidc将JsOidc客户端添加到解决方案中 IdentityServer 4工作正常(应该如此,我们没有更改任何内容) 所有客户端(MvcClient、ResourceOwner、Client和JsOidc)均按预期工作,并使用本地主机上的IdentityServer4进行身份验证:5000 从IS4到客户端的所有重定向(重定向uri)都正常工作 所有API调用都按预期工作 到目前为止还不错:-) 然后,我们将IIS设置为localhost:5000上IdentityServer4的反向代理,其域名具有有效的SSL(因此在浏览器中没有警告) 已配置IdentityServer4以使用ForwardHeaders中间件-IE app.UseForwardedHeaders(等…) 配置IIS以设置相关服务器变量(例如HTTP_X_转发的_主机、HTTP_X_转发的_协议、HTTP_X_转发的_端口) IIS在web.config中重写规则(已更新):-Reverse proxy 在IIS反向代理后面标识服务器4时,没有重定向回JsOidc客户端,reverse-proxy,identityserver4,openid-connect,Reverse Proxy,Identityserver4,Openid Connect,在IIS反向代理之后,为什么IdentityServer4不重定向回JsOidc客户端,但其他客户端按预期工作 测试设置 DOW加载了IdentityServer 4.0-release 使用\Quickstarts\6\u AsNetIdentity在VS2017中进行设置测试 然后从\Clients\src\JsOidc将JsOidc客户端添加到解决方案中 IdentityServer 4工作正常(应该如此,我们没有更改任何内容) 所有客户端(MvcClient、ResourceOwner、
表现出相同行为的图书馆
我们只在绝对必要的地方更改了IdentityServer4.Samples-release项目代码,以便运行这些测试
在我们的头发被拔掉之前,任何帮助都将不胜感激 解决方案是停止使用IIS,而将Nginx用于反向代理。但是,当在IIS rev proxy和Oidc客户机后面使用IDS4时,我们从来没有找到具体的不同之处
有关我们测试内容的更多详细信息,请参见:-
我真的不明白为什么在我发布这个问题后几分钟内就有人否决了这个问题。那个做这件事的人能告诉我他/她的理由吗?谢谢…请在发布到Public时删除敏感信息,例如:真实客户Id、客户机密、真实域名等。客户Id和机密是随机字符串,不是有效值。但谢谢你强调这一点,我与你的设置不同。我不使用出站url重写,因为我的AspNetCore理解代理背后的内容并返回正确的真实域。我提出了同样的解决方案:不能使用iis+url重写+aap作为真正生产AspNetCore的反向代理。
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:5000/{R:1}" />
<serverVariables>
<set name="HTTP_X_FORWARDED_HOST" value="{HTTP_HOST}" />
</serverVariables>
</rule>
</rules>
<outboundRules>
<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
<match filterByTags="A, Form, Img" pattern="^http(s)?://localhost:5000/(.*)" />
<action type="Rewrite" value="http{R:1}://www.wholesalesolar.co.uk/{R:2}" />
</rule>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlite(Configuration.GetConnectionString("DefaultConnection")));
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
services.AddMvc();
services.Configure<IISOptions>(iis =>
{
iis.AuthenticationDisplayName = "Windows";
iis.AutomaticAuthentication = false;
});
// Changed Builder to idsBuilder
var ids4Builder = services.AddIdentityServer(options =>
{
options.Events.RaiseErrorEvents = true;
options.Events.RaiseInformationEvents = true;
options.Events.RaiseFailureEvents = true;
options.Events.RaiseSuccessEvents = true;
options.PublicOrigin = "https://www.wholesalesolar.co.uk"; // Added this
})
.AddInMemoryIdentityResources(Config.GetIdentityResources())
.AddInMemoryApiResources(Config.GetApiResources())
.AddInMemoryClients(Config.GetClients())
.AddAspNetIdentity<ApplicationUser>();
if (Environment.IsDevelopment())
{
ids4Builder.AddDeveloperSigningCredential();
}
else
{
throw new Exception("need to configure key material");
}
services.AddAuthentication()
.AddGoogle(options =>
{
options.ClientId = "708996912208-9m4dkjb5hscn7cjrn5u0r4tbgkbj1fko.apps.googleusercontent.com";
options.ClientSecret = "wdfPY6t8H8cecgjlxud__4Gh";
});
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
// New code
var forwardedHeadersOptions = new ForwardedHeadersOptions()
{
ForwardedHeaders =
ForwardedHeaders.XForwardedFor |
ForwardedHeaders.XForwardedProto |
ForwardedHeaders.XForwardedHost
};
forwardedHeadersOptions.KnownNetworks.Clear();
forwardedHeadersOptions.KnownProxies.Clear();
app.UseForwardedHeaders(forwardedHeadersOptions);
// End new code
app.UseStaticFiles();
app.UseIdentityServer();
app.UseMvcWithDefaultRoute();
}