Nginx session丢失问题处理解决方法

Nginx session丢失问题处理解决方法,第1张

Nginxsession丢失问题处理解决方法

本文详细介绍了Nginx会话丢失问题的解决方案。原文根据示例代码非常详细,对大家的学习培训或者工作都有一定的参考价值。有必要的朋友陪我去了解一下。

用nginx反向代理tomcat的方式,很可能会出现会话丢失的问题。每个push请求JESSIONID都会改变,表示上一个会话丢失,然后建立一个新的会话。

第一种情况:

server{ listen80; server_namewww.jiahemdata.comwww.jiahemdata.cn; charsetutf-8; location/{ proxy_redirectoff; proxy_passhttp://127.0.0.1:8093; proxy_set_headerHost$host; proxy_set_headerReferer$http_referer; proxy_set_headerX-Real-Ip$remote_addr; proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for; } access_loglogs/tomcat_access.log; }

因为现在的nginx只监听一个端口号,不设置通道,所以一般都不容易出现会话丢失的问题。

第二种情况:

server{ listen80; server_namewww.jiahemdata.comwww.jiahemdata.cn; root/opt/tomcat-jhyx/webapps/jhyx/; charsetutf-8; location/{ proxy_passhttp://127.0.0.1:8093/jhyx/; proxy_set_headerHost$host; proxy_set_headerReferer$http_referer; proxy_set_headerX-Real-Ip$remote_addr; proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for; } access_loglogs/tomcat_access.log; }

这种指定tomcat的文件夹名的情况,不仅仅是端口号监控,还会导致每个请求都改变,导致会话丢失。

第三种情况:

server{ listen80; server_namewww.jiahemdata.comwww.jiahemdata.cn; root/opt/tomcat-jhyx/webapps/jhyx/; charsetutf-8; location/{ proxy_redirectoff; proxy_passhttp://127.0.0.1:8093/jhyx/; proxy_cookie_path/jhyx//;//设定cookie途径,进而不造成每一次产生请求产生变化。 proxy_cookie_path/jhyx/; proxy_set_headerHost$host; proxy_set_headerReferer$http_referer; proxy_set_headerX-Real-Ip$remote_addr; proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for; } access_loglogs/tomcat_access.log; }

此刻,我发现你的问题还没有得到处理。现在你在想,我已经设定好了饼干的方式。为什么不呢?那是因为你没有按你的要求推送cookie。

第四种情况:

server{ listen80; server_namewww.jiahemdata.comwww.jiahemdata.cn; root/opt/tomcat-jhyx/webapps/jhyx/; charsetutf-8; location/{ proxy_redirectoff; proxy_passhttp://127.0.0.1:8093/jhyx/; proxy_cookie_path/jhyx//; proxy_cookie_path/jhyx/; proxy_set_headerHost$host; proxy_set_headerReferer$http_referer; proxy_set_headerCookie$http_cookie;//请求推送时带上cookie信息内容 proxy_set_headerX-Real-Ip$remote_addr; proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for; } access_loglogs/tomcat_access.log; }

你期待在无尽的互联网中寻找合适的解决方案。

到目前为止,本文已经详细介绍了Nginx会话丢失问题的解决方案。有关Nginx会话丢失的大量信息,请搜索您以前的文章或再次访问下面的相关文章。期待你以后的申请!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/zz/774544.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-03
下一篇 2022-05-03

发表评论

登录后才能评论

评论列表(0条)

保存