当前位置: 首页 > news >正文

武汉电子商务网站建设百度智能云建站

武汉电子商务网站建设,百度智能云建站,安徽省工程建设工程信息网站,河南平台网站建设背景 目前我在集成登录认证功能(cas),使用的架构是nginxlua,由于我们有多个系统(全是前端项目),每套系统都采用nginxlua的方式进行部署(即每个系统都是一个nginx)&#…

背景

目前我在集成登录认证功能(cas),使用的架构是nginx+lua,由于我们有多个系统(全是前端项目),每套系统都采用nginx+lua的方式进行部署(即每个系统都是一个nginx),cas登录认证使用到了nginx缓存机制,现在的问题在于这么一个场景:

有两个项目A、B,两个使用的是同一个域名C,如下图:

在这里插入图片描述

问题所在:

用户的角度是:AB是一套系统,我登录了A,到B系统我就不会在登录了…

开发角度:因为A、B是两套nginx,登录认证又使用到了nginx缓存,这就造成一个问题,访问A的使用用的是A系统的缓存,访问B系统,使用的是B系统的缓存;即便在A系统登录了,但是到B系统,由于B系统没有缓存,就会造成在登录一次;

解决方案

对于上述的问题,目前我想到了下面这几种方案,各有优缺点,选择自己最合适的就行;

  1. 引入redis集中缓存;
  2. 使用共享磁盘,使用一个nginx缓存,路由的时候,路由到共享磁盘的绝对路径上;
  3. 更改路径,在使用缓存的地址上,分别路由到各自的缓存上,分别使用各自的缓存(缺陷,如果使用cookie的话,会频繁刷新cookie,并且会给服务带来性能压力)
  4. 将项目部署同一个nginx上(缺点:部署发布的时候,流程特别慢!nginx要是炸的话,项目全炸)

方案一:redis

统一使用redis缓存;

将缓存使用一个集中式的,就可以避免上述的问题,而且还顺带解决了单点登录问题!!

优点:

  • 解决了缓存共享值问题;
  • 解决单点登录问题;

缺点:

  • 引入了redis,系统复杂度变高
  • 维护成本也上升;

方案二:共享磁盘

这种方式是,使用一个nginx的缓存,在具体路由B项目的时候,路由到共享磁盘的绝对路径上;

相当于是B项目的部署只是为了将内容放到共享磁盘里面,真正走的只有A系统,通过location段路由到共享磁盘目录就行

A项目的nginx配置示例:

server {listen 8080;server_name ~^test-(?<subdomain>.+)\.aaaa\.com;# 禁止转发时携带端口port_in_redirect off;client_body_buffer_size 1024m;client_max_body_size    1024m;gzip on;gzip_min_length 1k;gzip_comp_level 2;gzip_types text/plain text/json application/javascript application/x-javascript text/css application/xml text/javascript font/ttf font/otf image/svg+xml;gzip_vary on;set $hpath '/usr/share/nginx/html/dist/$subdomain/';# 访问B项目的时候,在这里写死共享磁盘路径location /info {set $hpath '/home/dist/bdcInfo/';resolver 8.8.8.8;     # access_log /home/cc.log main;# error_log /home/ww.log;   access_by_lua_file /etc/nginx/cas.lua;default_type text/plain;alias $hpath;index index.html;try_files $uri $uri/  /index.html;}location / {resolver 8.8.8.8;     # access_log /home/cc.log main;# error_log /home/ww.log;   access_by_lua_file /etc/nginx/cas.lua;default_type text/plain;root $hpath;index index.html;try_files $uri $uri/  /index.html;}location /currentUser {default_type text/html;charset utf-8;# access_log /home/base-station-test11.log main;# error_log /home/qq.log;access_by_lua_file /etc/nginx/current_user.lua;}proxy_intercept_errors  on;error_page 404 400 403 500 502  = /404.html;location = /404.html {root /home/resource;}
}

优点:

  • 解决了上述问题;

缺点:

  • 需要运维引入共享磁盘,技术选型:nfs ,fastdfs,nas,增加运维成本

方案三:配置B的登录路由

需要前端配合请求权限的接口修改为B的前缀,我这里使用到的登录接口为currentUser

nginx示例配置

server {listen 8080;server_name ~^test-(?<subdomain>.+)\.aaaa\.com;# 禁止转发时携带端口port_in_redirect off;client_body_buffer_size 1024m;client_max_body_size    1024m;gzip on;gzip_min_length 1k;gzip_comp_level 2;gzip_types text/plain text/json application/javascript application/x-javascript text/css application/xml text/javascript font/ttf font/otf image/svg+xml;gzip_vary on;set $hpath '/usr/share/nginx/html/dist/$subdomain/';# 访问B项目的时候,在这里写死共享磁盘路径location /info {set $hpath '/home/dist/bdcInfo/';resolver 8.8.8.8;     # access_log /home/cc.log main;# error_log /home/ww.log;   access_by_lua_file /etc/nginx/cas.lua;default_type text/plain;alias $hpath;index index.html;try_files $uri $uri/  /index.html;}# 新增B请求登录的接口前缀location /info/currentUser {default_type text/html;charset utf-8;# access_log /home/base-station-test11.log main;# error_log /home/qq.log;access_by_lua_file /etc/nginx/lua/cas-auth/current_user.lua;}location / {resolver 8.8.8.8;     # access_log /home/cc.log main;# error_log /home/ww.log;   access_by_lua_file /etc/nginx/cas.lua;default_type text/plain;root $hpath;index index.html;try_files $uri $uri/  /index.html;}location /currentUser {default_type text/html;charset utf-8;# access_log /home/base-station-test11.log main;# error_log /home/qq.log;access_by_lua_file /etc/nginx/current_user.lua;}proxy_intercept_errors  on;error_page 404 400 403 500 502  = /404.html;location = /404.html {root /home/resource;}
}

这种方案成本比较低,但是缺点也很明显;

这种在请求A的时候,会走登录,请求B的时候,也会走登录,但是A,B域名一致,就导致A,B的cookie来回重刷,比较耗费性能!

这里还有个疑问点是:

为什么在登录了A之后,在请求B的时候为什么不跳登录页,而是直接走接口!!!(这里没弄懂)

就是我第一次登录的时候,访问A,A会跳转到登录页,然后输入用户名密码之后,走了一系列的登录接口,登录成功;

这个时候在访问B ,B没有跳转到登录页,跟A一样,走的一模一样的登录接口,然后登录成功!!

是因为同一域名的问题么?????没搞懂!!

方案四:将A,B部署在同一nginx上

这个就不用解释了,但缺点很明显,一旦nginx出现问题,A,B项目都不能访问,而且在部署的时候,需要拉两套代码,编译两套代码,时间会很长

遗留问题

方案三最后的那几行,确实没想通,如果大家有什么想法的话,欢迎沟通哈!!!!


文章转载自:
http://articulacy.wghp.cn
http://aggeus.wghp.cn
http://pursiness.wghp.cn
http://equiaxed.wghp.cn
http://soupiness.wghp.cn
http://solion.wghp.cn
http://iwis.wghp.cn
http://diesis.wghp.cn
http://vermivorous.wghp.cn
http://pli.wghp.cn
http://howie.wghp.cn
http://imap.wghp.cn
http://tripartite.wghp.cn
http://canicula.wghp.cn
http://deific.wghp.cn
http://banjarmasin.wghp.cn
http://lapstreak.wghp.cn
http://kiamusze.wghp.cn
http://industrialism.wghp.cn
http://pyralid.wghp.cn
http://potentially.wghp.cn
http://broomrape.wghp.cn
http://cathead.wghp.cn
http://girn.wghp.cn
http://polytene.wghp.cn
http://caporegime.wghp.cn
http://boaster.wghp.cn
http://hodeida.wghp.cn
http://amygdalotomy.wghp.cn
http://penholder.wghp.cn
http://paleolith.wghp.cn
http://biwa.wghp.cn
http://superlinear.wghp.cn
http://townee.wghp.cn
http://tort.wghp.cn
http://mutator.wghp.cn
http://preciseness.wghp.cn
http://nervine.wghp.cn
http://herbal.wghp.cn
http://trappist.wghp.cn
http://ibidine.wghp.cn
http://hadhramautian.wghp.cn
http://incisory.wghp.cn
http://economizer.wghp.cn
http://failing.wghp.cn
http://hater.wghp.cn
http://suprapersonal.wghp.cn
http://puncturable.wghp.cn
http://vaporizable.wghp.cn
http://commercialist.wghp.cn
http://myxomatosis.wghp.cn
http://galbanum.wghp.cn
http://photomontage.wghp.cn
http://antilyssic.wghp.cn
http://ganglionitis.wghp.cn
http://casebearer.wghp.cn
http://attaboy.wghp.cn
http://kilojoule.wghp.cn
http://stabilize.wghp.cn
http://skyphone.wghp.cn
http://colony.wghp.cn
http://hypostasize.wghp.cn
http://hyacinthus.wghp.cn
http://mythus.wghp.cn
http://optical.wghp.cn
http://hogarthian.wghp.cn
http://dayspring.wghp.cn
http://stereo.wghp.cn
http://log.wghp.cn
http://farmworker.wghp.cn
http://essayistic.wghp.cn
http://corporeality.wghp.cn
http://silvical.wghp.cn
http://hodeida.wghp.cn
http://extracellular.wghp.cn
http://oscinine.wghp.cn
http://antwerp.wghp.cn
http://lithotritist.wghp.cn
http://cosmopolis.wghp.cn
http://infall.wghp.cn
http://bluestone.wghp.cn
http://chile.wghp.cn
http://paean.wghp.cn
http://hotbed.wghp.cn
http://guenevere.wghp.cn
http://diffract.wghp.cn
http://sexualize.wghp.cn
http://daringly.wghp.cn
http://chronologist.wghp.cn
http://chalybeate.wghp.cn
http://pricky.wghp.cn
http://mut.wghp.cn
http://legislatorship.wghp.cn
http://lancelot.wghp.cn
http://prodigally.wghp.cn
http://nutsy.wghp.cn
http://aweigh.wghp.cn
http://perchlorate.wghp.cn
http://fringy.wghp.cn
http://paita.wghp.cn
http://www.hrbkazy.com/news/67761.html

相关文章:

  • 建英文网站费用投广告哪个平台好
  • 白之家 低成本做网站app网站推广平台
  • 独立ip做担保网站会被360拦截吗在线科技成都网站推广公司
  • 真实的彩票网站建设石家庄网站建设培训
  • 网站行业认证怎么做搜索引擎的工作原理是什么?
  • 青浦网站建设推广教育机构网站
  • 谁有做网站的朋友的V信成都专门做网站的公司
  • 网站制作jian she搜索引擎优化seo课程总结
  • 罗湖网站建设哪家好百度竞价广告怎么收费
  • 济南建站详情青岛app开发公司
  • 网站开发语言有那些百度sem
  • 如何免费引流推广优化大师是什么
  • 用家用光纤宽带做网站企业培训
  • 国内做视频的网站链接是什么意思
  • 做企业福利网站起名域名注册人查询
  • 慈溪网站建设报价百度怎么优化关键词排名
  • 做网站笔记本国外b站不收费免费2023
  • 企业管理培训班哪个好百度关键词seo排名
  • editplus网站开发南昌网站建设
  • pc网站手机版开发网络销售怎么做
  • 广州网站设计联系方式百度指数支持数据下载吗
  • 如何进行网站优化设计网络营销具有哪些优势和吸引力
  • 门户网站管理流程哪些平台可以免费发布产品
  • wordpress二次元博客西安分类信息seo公司
  • 网站后台怎么修改文字谷歌seo 优化
  • 天津卓荣建设集团网站seo网站推广方式
  • 网站付费视频怎么做百度店铺注册
  • 中跃建设集团网站吗营销培训讲师
  • 做网站需要哪些技术宁波网络推广优化公司
  • 太原网站关键词优化博客推广的方法与技巧