我们正在尝试按照 WSO2 文档在集群中配置 WSO2 API Manager 2.1.0。我们有:
- 两个网关组成的集群
- 由两个 key 管理器组成的集群
- 由两个流量管理器组成的集群
作为前端负载均衡器,我们使用 NGINX。除了这方面之外,一切正常:
当我尝试登录发布者或存储时,请求将发送到负载均衡器,负载均衡器将请求重定向到 key 管理器。 KM1的日志是:
INFO {org.wso2.carbon.core.services.util.CarbonAuthenticationUtil} - '[email protected] [-1234]' logged in at [2018-02-01 15:23:15,102+0100] {org.wso2.carbon.core.services.util.CarbonAuthenticationUtil}
而在另一个日志(KM2)中是:
TID: [-1234] [] [2018-02-01 15:23:15,165] WARN {org.wso2.carbon.server.admin.module.handler.AuthenticationHandler} - Illegal access attempt at [2018-02-01 15:23:15,0165] from IP address xxxxx while trying to authenticate access to service LoggedUserInfoAdmin {org.wso2.carbon.server.admin.module.handler.AuthenticationHandler}
最终的结果是我无法访问商店或发布商。 如果两个 KM 之一停止,则一切正常。 您对我应该如何配置 KM 或 TM 有什么建议吗? 非常感谢
最佳答案
发生这种情况是因为您尚未为 key 管理器启用粘性 session 。
有两个调用发送至 key 管理器,并且这两个调用应重定向至同一个 key 管理器。在您的情况下,请求以循环方式进行负载平衡。因此,第二次调用失败,因为 session 是在另一个节点中创建的。
https://docs.wso2.com/display/CLUSTER44x/Configuring+NGINX
Why thrift key validation is not recommend in production deployments
Thrift key validation does not work when we have a load balancer fronted key manager. The reason for this is that most load balancers are not capable of routing traffic in a session-aware manner. Therefore, in such cases, it's always recommended to use the WS key validation client. When we use web service clients we need to enable a sticky session at the load balancer level. Moreover, we need to give a session cookie that we've used to handle session stickiness.
关于nginx - WSO2 API 管理器集群 : Login error to Publisher and Store,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48565086/