当前位置:网站首页>使用Tengine解决负载均衡的Session问题
使用Tengine解决负载均衡的Session问题
2022-07-03 15:03:00 【星哥玩云】
事情的经过时这样的~~,我看了好多好多百度中nginx负载均衡中解决session问题的方式,我选择了研究url_hash的方式。经过一番配置之后,我越发觉得这百度搜出来的帖子也太过久远了吧,去http://wiki.nginx.org/上找了找这个模块
,在github下载的位置上看到了这样一段话:
NOTE: This module is obsolete as of Nginx 1.7.2, which includes the hashdirective. This repository remains for historical interest only. 我的理解是此版本是绝对的使用nginx1,7,2,此库仅为历史感兴趣的参考,而百度翻译则是此模块为过时的,我就无法理解了。
正在迷茫之际,我看到了tengine,这是淘宝对nginx的一种扩展的优化吧。然后我就转而研究这个了~~,发现在tengine之中有一个叫做ngx_http_upstream_session_sticky_module的模块,很是贴合我的目的,他是利用用户的cookie来保持对session的支持。具体原理还有待研究,总之得试试吧~~
安装过程可以参考这个:http://www.linuxidc.com/Linux/2015-09/123050.htm 。(指出这个文章有问题的地方,在安装nginx的时候使用 ./configure --prefix=/opt/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/src/openssl-1.0.1h --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.35 --with-jemalloc=/usr/local/jemalloc-3.6.0这个命令)
经过各种踩坑之后,整好了:(这个界面也是尊重nginx,依然那么简约 。 - - !)
那么我们就来试试那个神奇的模块吧,配置如下:
upstream rock{ server 127.0.0.1:8081; server 127.0.0.1:8082; session_sticky; }
server { server_name www.linuxidc.com rockcoding.com; listen 80; index index.html index.htm index.jsp; location / { proxy_pass http://rock; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # access_log /data/log/rockman/www.linuxidc.com main; #日志文件 } }
公司的同事,对于外网来说ip都一样,只要访问到不同的两台服务器且连续刷新不会改变session不会失效(其实就是不会跳转到另一台服务器),那么就成功了。两台电脑访问,或者不同的浏览器访问都可以,模块式基于cookie来判断的~
嗯,比ip_hash强多了,但是要编译那么多东西,总觉得还需要再深入研究一下,才方便使用这个tengine吧~
边栏推荐
- [ue4] Niagara's indirect draw
- 【Transformer】入门篇-哈佛Harvard NLP的原作者在2018年初以逐行实现的形式呈现了论文The Annotated Transformer
- [pytorch learning notes] transforms
- [opengl] bone animation blending effect
- [transformer] Introduction - the original author of Harvard NLP presented the annotated transformer in the form of line by line implementation in early 2018
- Global and Chinese markets for transparent OLED displays 2022-2028: Research Report on technology, participants, trends, market size and share
- The latest M1 dedicated Au update Adobe audit CC 2021 Chinese direct installation version has solved the problems of M1 installation without flash back!
- 远程服务器后台挂起 nohup
- Global and Chinese markets for sterile packaging 2022-2028: Research Report on technology, participants, trends, market size and share
- Global and Chinese markets for indoor HDTV antennas 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢

Rasterization: a practical implementation (2)

4-20-4-23 concurrent server, TCP state transition;

Unity hierarchical bounding box AABB tree

Yolov5系列(一)——网络可视化工具netron
![[ue4] material and shader permutation](/img/8f/7743ac378490fcd7b9ecc5b4c2ef2a.jpg)
[ue4] material and shader permutation

High quality workplace human beings must use software to recommend, and you certainly don't know the last one

【Transformer】入门篇-哈佛Harvard NLP的原作者在2018年初以逐行实现的形式呈现了论文The Annotated Transformer

零拷贝底层剖析

Pytorch深度学习和目标检测实战笔记
![[wechat applet] wxss template style](/img/28/f9d12bf761e25f9564d92697cf049d.png)
[wechat applet] wxss template style
随机推荐
【pytorch学习笔记】Datasets and Dataloaders
【pytorch学习笔记】Transforms
第04章_逻辑架构
App全局异常捕获
C language memory function
My QT learning path -- how qdatetimeedit is empty
el-switch 赋值后状态不变化
Qt—绘制其他东西
5.2-5.3
C string format (decimal point retention / decimal conversion, etc.)
556. The next larger element III: simple construction simulation questions
Search in the two-dimensional array of leetcode sword offer (10)
NOI OPENJUDGE 1.4(15)
Global and Chinese markets for sterile packaging 2022-2028: Research Report on technology, participants, trends, market size and share
Chapter 14 class part 1
Troubleshooting method of CPU surge
4-20-4-23 concurrent server, TCP state transition;
[Yu Yue education] scientific computing and MATLAB language reference materials of Central South University
2022/02/14
PS tips - draw green earth with a brush