首页 新闻 会员 周边 捐助

使用nginx 做代理登录出现了问题(求解)

0
悬赏园豆:20 [待解决问题]

nginx 配置如下

upstream crserver {
#ip_hash;
server 127.0.0.1:8090;
server 127.0.0.1:8091;
}
代码:
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
/* Config config = new Config();
config.useSingleServer()
.setAddress("redis://127.0.0.1:6379");
RedissonClient redissonClient = Redisson.create(config);
String resourceName="REDLOCK_KEY";
RLock lock= redissonClient.getLock(resourceName);
RedissonRedLock redLock = new RedissonRedLock(lock);
boolean isLock;
try { // isLock = redLock.tryLock(); // 500ms拿不到锁, 就认为获取锁失败。10000ms即10s是锁失效时间。
isLock = redLock.tryLock(500, 10000, TimeUnit.MILLISECONDS);
log.info("lock is "+isLock);
if (isLock) {
log.info("JWTFilter doFilterInternal :time:"+ DateFormatUtils.format(new Date(),"yyyy-MM-dd hh:mm:ss"));
//从url中根据参数获取值
String jwt = obtainParameter(request, GlobalConstant.jwt);
Authentication authentication=null;
if (StringUtils.hasText(jwt)) {
getAuthentication( jwt ,response);

            }
            filterChain.doFilter(request, response);
        }
    } catch (Exception e) {
        log.error(e.getMessage());
    } finally {
        redLock.unlock();
    }*/
    log.info("JWTFilter  doFilterInternal  :time:"+ DateFormatUtils.format(new Date(),"yyyy-MM-dd hh:mm:ss"));
    //从url中根据参数获取值
    String jwt = obtainParameter(request, GlobalConstant.jwt);
    Authentication authentication=null;
    if (StringUtils.hasText(jwt)) {
        getAuthentication( jwt ,response);

    }
    filterChain.doFilter(request, response);
}

8091机器日志:
2021-06-23 10:35:07.626 INFO 16892 --- [nio-8091-exec-1] c.e.d.config.security.filter.JWTFilter : JWTFilter doFilterInternal :time:2021-06-23 10:35:07
2021-06-23 10:35:07.665 INFO 16892 --- [nio-8091-exec-2] c.e.d.config.security.filter.JWTFilter : JWTFilter doFilterInternal :time:2021-06-23 10:35:07
2021-06-23 10:35:07.675 INFO 16892 --- [nio-8091-exec-3] c.e.d.config.security.filter.JWTFilter : JWTFilter doFilterInternal :time:2021-06-23 10:35:07
2021-06-23 10:35:07.683 INFO 16892 --- [nio-8091-exec-4] c.e.d.config.security.filter.JWTFilter : JWTFilter doFilterInternal :time:2021-06-23 10:35:07
2021-06-23 10:35:07.692 INFO 16892 --- [nio-8091-exec-5] c.e.d.config.security.filter.JWTFilter : JWTFilter doFilterInternal :time:2021-06-23 10:35:07

8090机器日志:
2021-06-23 10:35:07.550 INFO 13580 --- [nio-8090-exec-1] c.e.d.config.security.filter.JWTFilter : JWTFilter doFilterInternal :time:2021-06-23 10:35:07
2021-06-23 10:35:07.637 INFO 13580 --- [nio-8090-exec-2] c.e.d.config.security.filter.JWTFilter : JWTFilter doFilterInternal :time:2021-06-23 10:35:07
2021-06-23 10:35:07.670 INFO 13580 --- [nio-8090-exec-3] c.e.d.config.security.filter.JWTFilter : JWTFilter doFilterInternal :time:2021-06-23 10:35:07
2021-06-23 10:35:07.679 INFO 13580 --- [nio-8090-exec-4] c.e.d.config.security.filter.JWTFilter : JWTFilter doFilterInternal :time:2021-06-23 10:35:07
2021-06-23 10:35:07.687 INFO 13580 --- [nio-8090-exec-5] c.e.d.config.security.filter.JWTFilter : JWTFilter doFilterInternal :time:2021-06-23 10:35:07
2021-06-23 10:35:07.696 INFO 13580 --- [nio-8090-exec-6] c.e.d.config.security.filter.JWTFilter : JWTFilter doFilterInternal :time:2021-06-23 10:35:07

问题:
为什么在doFilter这里相互调用导致没有进入登录逻辑

倔强的小白-的主页 倔强的小白- | 初学一级 | 园豆:182
提问于:2021-06-23 10:49
< >
分享
所有回答(1)
0

把这个redis 锁去掉看看

Tom.汤 | 园豆:3058 (老鸟四级) | 2021-06-23 13:24

测试的时候,已经注释去掉了和这个没有关系的。

支持(0) 反对(0) 倔强的小白- | 园豆:182 (初学一级) | 2021-06-23 14:04
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册