NutzCN Logo
问答 nutzboot 开发网站在线上服务器 session 几分钟就失效了 不知道什么原因造成的
发布于 1474天前 作者 CHQ 2152 次浏览 复制 上一个帖子 下一个帖子
标签:

nutzboot 开发网站在线上服务器 session 几分钟就失效了 不知道什么原因造成的,本地测试没有这个问题,头疼

短地址: 线上运行日志
https://nutz.cn/s/c/rk

19 回复
                proxy_redirect off;
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		client_max_body_size  300M;

或者试试

proxy_cookie_path  /xx /xx

nginx --> nutzboot 这样的结构吗?

是的, 使用jetty内置运行方式

匪夷所思,没遇到过,重装系统?

多少个实例, nginx和nutzboot分别多少个?

这个服务器上就三个站点nutzboot, 使用宝塔面板
Nginx

     # 前端访问地址
    location / {
      try_files $uri $uri/ /index.html;
    }
 
	  # API接口|NT接口|微信接口|线上资源地址|SQL监控&API文档
    location ~* /(api|nt|wx|upload|attachment|swagger|druid) {
			proxy_http_version 1.1;
			proxy_pass http://127.0.0.1:98;
			proxy_set_header Host $http_host;
			proxy_set_header X-Forwarded-For $remote_addr;
	  }

你没回答呢, nutzboot是多少个实例/Jvm进程

目测是单个nutzboot进程?

日志

[DEBUG] 15:33:34.619 com.yunqi.nt.common.processor.LogTimeProcessor.process(LogTimeProcessor.java:29) - [POST]URI=/api/scenic/list 6ms
[DEBUG] 15:33:48.817 org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:291) - batch acquisition of 0 triggers
[DEBUG] 15:34:16.200 org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:291) - batch acquisition of 0 triggers
[DEBUG] 15:34:42.848 org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:291) - batch acquisition of 0 triggers
[DEBUG] 15:35:07.518 org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:291) - batch acquisition of 0 triggers
[DEBUG] 15:35:35.713 org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:291) - batch acquisition of 0 triggers
[DEBUG] 15:36:03.835 org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:291) - batch acquisition of 0 triggers
[DEBUG] 15:36:33.809 org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:291) - batch acquisition of 0 triggers
[DEBUG] 15:36:51.960 org.apache.shiro.session.mgt.DefaultSessionManager.retrieveSession(DefaultSessionManager.java:218) - Unable to resolve session ID from SessionKey [org.apache.shiro.web.session.mgt.WebSessionKey@6acd96c7].  Returning null to indicate a session could not be found.
[DEBUG] 15:36:51.960 org.nutz.mvc.impl.UrlMappingImpl.get(UrlMappingImpl.java:103) - Found mapping for [POST] path=/merch/goods/category : MerchGoodsApiController.category(MerchGoodsApiController.java:258)
[DEBUG] 15:36:51.960 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:166) - Get 'merchGoodsApiController'<class com.yunqi.nt.modules.api.merch.goods.MerchGoodsApiController>
[DEBUG] 15:36:51.962 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:166) - Get 'merchAccountService'<class com.yunqi.nt.modules.merch.service.MerchAccountService>
[DEBUG] 15:36:51.964 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:391) - SELECT * FROM ims_merch_account  WHERE merchId=?
    |                                1 |
    |----------------------------------|
    | ffc9832237f347fdb5e4e01f09b24b63 |
  For example:> "SELECT * FROM ims_merch_account  WHERE merchId='ffc9832237f347fdb5e4e01f09b24b63'"
[DEBUG] 15:36:51.966 org.apache.shiro.session.mgt.DefaultSessionManager.retrieveSession(DefaultSessionManager.java:218) - Unable to resolve session ID from SessionKey [org.apache.shiro.web.session.mgt.WebSessionKey@699c679d].  Returning null to indicate a session could not be found.
[DEBUG] 15:36:51.966 org.nutz.mvc.impl.UrlMappingImpl.get(UrlMappingImpl.java:103) - Found mapping for [POST] path=/merch/goods/list : MerchGoodsApiController.list(MerchGoodsApiController.java:57)
[DEBUG] 15:36:51.966 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:166) - Get 'merchGoodsApiController'<class com.yunqi.nt.modules.api.merch.goods.MerchGoodsApiController>
[DEBUG] 15:36:51.966 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:391) - SELECT * FROM ims_goods_category  WHERE merchId=? ORDER BY location ASC  
    |                                1 |
    |----------------------------------|
    | ffc9832237f347fdb5e4e01f09b24b63 |
  For example:> "SELECT * FROM ims_goods_category  WHERE merchId='ffc9832237f347fdb5e4e01f09b24b63' ORDER BY location ASC  "
[DEBUG] 15:36:51.967 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:166) - Get 'merchAccountService'<class com.yunqi.nt.modules.merch.service.MerchAccountService>
[DEBUG] 15:36:51.968 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:391) - SELECT * FROM ims_merch_account  WHERE merchId=?
    |                                1 |
    |----------------------------------|
    | ffc9832237f347fdb5e4e01f09b24b63 |
  For example:> "SELECT * FROM ims_merch_account  WHERE merchId='ffc9832237f347fdb5e4e01f09b24b63'"
[DEBUG] 15:36:51.969 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:391) - SELECT * FROM ims_goods  WHERE merchId=? ORDER BY createAt DESC   LIMIT 0, 10 
    |                                1 |
    |----------------------------------|
    | ffc9832237f347fdb5e4e01f09b24b63 |
  For example:> "SELECT * FROM ims_goods  WHERE merchId='ffc9832237f347fdb5e4e01f09b24b63' ORDER BY createAt DESC   LIMIT 0, 10 "
[DEBUG] 15:36:51.975 com.yunqi.nt.common.processor.LogTimeProcessor.process(LogTimeProcessor.java:29) - [POST]URI=/merch/goods/category 15ms
[DEBUG] 15:36:51.988 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:391) - SELECT COUNT(*) FROM ims_goods  WHERE merchId=?
    |                                1 |
    |----------------------------------|
    | ffc9832237f347fdb5e4e01f09b24b63 |
  For example:> "SELECT COUNT(*) FROM ims_goods  WHERE merchId='ffc9832237f347fdb5e4e01f09b24b63'"
[DEBUG] 15:36:51.993 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:391) - SELECT * FROM ims_goods_category  WHERE id=?
    |                                1 |
    |----------------------------------|
    | fed81ffb4f464b90afc0673e557897f1 |
  For example:> "SELECT * FROM ims_goods_category  WHERE id='fed81ffb4f464b90afc0673e557897f1'"
[DEBUG] 15:36:51.994 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:391) - SELECT * FROM ims_goods_category  WHERE id=?
    |                                1 |
    |----------------------------------|
    | 0e8684725937464696da3282933219b2 |
  For example:> "SELECT * FROM ims_goods_category  WHERE id='0e8684725937464696da3282933219b2'"
[DEBUG] 15:36:51.995 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:391) - SELECT * FROM ims_goods_category  WHERE id=?
    |                                1 |
    |----------------------------------|
    | 743476e891bb4fd8ac81bdc46f578987 |
  For example:> "SELECT * FROM ims_goods_category  WHERE id='743476e891bb4fd8ac81bdc46f578987'"
[DEBUG] 15:36:51.996 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:391) - SELECT * FROM ims_goods_category  WHERE id=?
    |                                1 |
    |----------------------------------|
    | 07f985f9b9384ab8a5904d826cb22ea8 |
  For example:> "SELECT * FROM ims_goods_category  WHERE id='07f985f9b9384ab8a5904d826cb22ea8'"
[DEBUG] 15:36:51.997 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:391) - SELECT * FROM ims_goods_category  WHERE id=?
    |                                1 |
    |----------------------------------|
    | 743476e891bb4fd8ac81bdc46f578987 |
  For example:> "SELECT * FROM ims_goods_category  WHERE id='743476e891bb4fd8ac81bdc46f578987'"
[DEBUG] 15:36:51.998 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:391) - SELECT * FROM ims_goods_category  WHERE id=?
    |                                1 |
    |----------------------------------|
    | 07f985f9b9384ab8a5904d826cb22ea8 |
  For example:> "SELECT * FROM ims_goods_category  WHERE id='07f985f9b9384ab8a5904d826cb22ea8'"
[DEBUG] 15:36:52.000 com.yunqi.nt.common.processor.LogTimeProcessor.process(LogTimeProcessor.java:29) - [POST]URI=/merch/goods/list 34ms
[DEBUG] 15:37:03.380 org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:291) - batch acquisition of 0 triggers
[DEBUG] 15:37:27.248 org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:291) - batch acquisition of 0 triggers
[DEBUG] 15:37:51.033 org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:291) - batch acquisition of 0 triggers
[DEBUG] 15:38:13.463 org.apache.shiro.web.servlet.SimpleCookie.readValue(SimpleCookie.java:389) - Found 'sid' cookie value [q50i8camlqibao01ddjp7m74n9]
[DEBUG] 15:38:13.464 org.apache.shiro.web.session.mgt.DefaultWebSessionManager.onInvalidation(DefaultWebSessionManager.java:300) - Referenced session was invalid.  Removing session ID cookie.
[DEBUG] 15:38:13.639 org.apache.shiro.web.servlet.SimpleCookie.addCookieHeader(SimpleCookie.java:226) - Added HttpServletResponse Cookie [sid=deleteMe; Path=/; Max-Age=0; Expires=Tue, 10-Nov-2020 07:38:13 GMT]
[DEBUG] 15:38:13.640 org.nutz.mvc.impl.UrlMappingImpl.get(UrlMappingImpl.java:103) - Found mapping for [POST] path=/nt/info : OpenLoginController.info(OpenLoginController.java:121)
[DEBUG] 15:38:13.640 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:166) - Get 'openLoginController'<class com.yunqi.nt.modules.api.serve.open.OpenLoginController>
[DEBUG] 15:38:13.641 org.apache.shiro.session.mgt.DefaultSessionManager.create(DefaultSessionManager.java:175) - Creating new EIS record for new session instance [org.apache.shiro.session.mgt.SimpleSession,id=null]
[DEBUG] 15:38:13.641 org.apache.shiro.web.servlet.SimpleCookie.addCookieHeader(SimpleCookie.java:226) - Added HttpServletResponse Cookie [sid=2clkgs74pug6nphh0042vf1gu6; Path=/; Max-Age=946080000; Expires=Fri, 04-Nov-2050 07:38:13 GMT; HttpOnly]
[DEBUG] 15:38:13.642 com.yunqi.nt.common.processor.LogTimeProcessor.process(LogTimeProcessor.java:29) - [POST]URI=/nt/info 2ms
[DEBUG] 15:38:20.937 org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:291) - batch acquisition of 0 triggers

那就跟nutzboot没关系, 查nginx/宝塔的配置吧

宝塔还敢用,厉害……

结果一下:跟宝塔没有关系……
服务器系统:CentOS-7.4
代理服务器:Nginx
应用服务器:Jetty
排查出的问题是:Nginx 配置后台资源,访问后台API接口,导致反向代理cookie丢失的问题

    location / { // 这样访问 没有问题
      try_files $uri $uri/ /index.html;
    }
    location /admin{ // 这样访问 有问题
           try_files $uri $uri/ /index.html;
    }

try_files是php时代的东西, proxy_pass才是正路

一大早我应该把nginx配置贴全,就省得你走这么多弯路了……

upstream demo_server {  
    server 127.0.0.1:9527;  
    server 127.0.0.1:9528;  
}

map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
}

server {
	#listen 80;
	listen 443 ssl;
	#if ( $scheme = "http" ) {
        #    rewrite ^(.*) https://$server_name$1 permanent;
	#}
	server_name demo.budwk.com;
	server_name_in_redirect off;
	ssl_certificate /etc/nginx/ssl/fullchain.cer;
	ssl_certificate_key /etc/nginx/ssl/budwk.com.key;
	ssl_session_timeout 5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
	add_header "X-UA-Compatible" "IE=Edge, chrome=1";

	#root  /data/static;
	#index index.html;

	location / {
           root    /data/static;
           try_files $uri /index.html;
           index  index.html;
        }

	location @router {
           rewrite ^.*$ /index.html last;
        }

	location ^~ /api {
		proxy_pass http://demo_server/api;
		proxy_redirect off;
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		client_max_body_size  300M;
	}

	location ^~ /websocket {
		proxy_pass http://demo_server/websocket;
		proxy_redirect    off;
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection $connection_upgrade;
	}

	location /swagger {
		proxy_pass http://demo_server/swagger;
		proxy_redirect off;
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	}

	location /upload {
		proxy_pass http://demo_server/upload;
		proxy_redirect off;
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	}

	location /open {
		proxy_pass http://demo_server/open;
		proxy_redirect off;
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	}
	
}
添加回复
请先登陆
回到顶部