Rewriting URLs in discovery page (.well-known/open

2020-03-04 09:34发布

问题:

I have IdentityServer4 running behind a load balancer that redirects https calls to http resources. This means that my IdentityServer will be running on http but will need to show https URLs in it's discovery page (.well-known/openid-configuration).

What's the most elegant way to transform http urls on this page to https?

回答1:

Set the PublicOrigin option (see docs).

services.AddIdentityServer( options => 
    options.PublicOrigin = "https://foo.bar.com" 
)
    .AddSigningCredential(...)
    .AddValidationKey(...)
    .AddInMemoryIdentityResources(...)
    .AddInMemoryClients(...)
    .AddProfileService<...>();