Tips for running IdentityServer4 in a web farm

自闭症网瘾萝莉.ら 提交于 2021-01-27 07:27:23

问题


Does anyone have experience with running IdentityServer4 in a web farm (multiple IIS servers) behind a load balancer? We've had some issues getting 2 servers to work together. I didn't see a deployment guide for IdentityServer4. There is one here for IdentityServer3.

https://identityserver.github.io/Documentation/docsv2/advanced/deployment.html

We have implemented the DataProtection in the Startup.cs.

StackExchange.Redis.ConnectionMultiplexer connectionMultiplexer = RedisConnectionFactory.GetConnection();
        RedisKey redisKey = appSettings.RedisKeyPrefix;
        services.AddDataProtection().PersistKeysToRedis(connectionMultiplexer, redisKey);

The load balancer is running in layer 7. It decrypts the SSL and re-encrypts so it can inspect and update the headers with the X-Forwarded-For value. We added the ForwardedHeadersOptions in the Startup.cs for this so the application sees the IP of the end-user and not the load balancer.

services.Configure<ForwardedHeadersOptions>(options =>
        {
            options.ForwardedHeaders =
                ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
            options.KnownNetworks.Add(new IPNetwork(...); 
            options.KnownProxies.Add(...); 
        });

Our configuration and operational stores both use SQL.

Am I missing something to ensure 2 servers in a farm can work together? Should we expect that both cookie and token validation should process correctly when inspecting the cookies and tokens initially generated by the other server in the farm?

来源:https://stackoverflow.com/questions/52174647/tips-for-running-identityserver4-in-a-web-farm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!