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

惠州专业网站建设公司哪里有seo81

惠州专业网站建设公司哪里有,seo81,200元自助网站建设,wordpress官方的三个主题好排名文章目录 upstream实现后台应用服务负载均衡&高可用proxy_set_header参数 upstream实现后台应用服务负载均衡&高可用 角色IPnginx172.168.110.2后端应用服务1172.168.110.3后端应用服务2172.168.110.4后端应用服务3(备用)172.168.110.5 示例如下: upstre…

文章目录

  • upstream实现后台应用服务负载均衡&高可用
  • proxy_set_header参数

upstream实现后台应用服务负载均衡&高可用

角色IP
nginx172.168.110.2
后端应用服务1172.168.110.3
后端应用服务2172.168.110.4
后端应用服务3(备用)172.168.110.5

示例如下:

upstream myservers {server 172.168.110.3:9003 weight=1  max_fails=2  fail_timeout=30;server 172.168.110.4:9003 weight=2  max_fails=2  fail_timeout=30;server 172.168.110.5:9003 backup;
}server {listen 3333;server_name localhost;location / {proxy_pass http://myservers/;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}

上面配置解释:
weight:访问权重。如果不配置权重情况下,用户请求默认是轮询访问后端应用服务1、服务2 ,例如10次请求中,5次访问服务1,5次访问服务2。当权重设置1和2后,那么后端应用服务1、服务2的请求访问比例变为1:2。
max_fails=2 fail_timeout=30:在30(fail_timeout)s内,如果某个服务出现2(max_fails)次访问失败,那么在接下来的30s(fail_timeout)s中,不会给将请求转发给该服务。
backup:当upstream中所有服务都访问失败,而进入fail_timeout时,那么此时会将请求转发给配置了backup的备用服务器进行处理。

Nginx实现应用服务高可用原理:假设上面示例中,后台应用服务1挂掉,此时用户发起请求,假设请求刚好落到那台故障的后台应用服务1,此时前端用户是否会看到报错,例如404?答案是否,因为nginx尝试让应用服务1处理请求,发现服务1挂掉(例如发现应用服务的端口不通、连接超时等),不会马上返回错误结果给用户,而是转而让后台应用服务2去处理请求,服务2响应成功后,nginx才会把响应的成功结果响应给用户。故而哪怕服务1出现故障,nginx在收到多次请求时,不会说部分请求能成功,部分请求失败,即对用户来说,是无感的,此方式为nginx upstream的被动检测,即每次收到请求时进行处理时才进行检测,还有一种为主动检测,即nginx定期对后端服务进行检测,这样效率更较高,对用户更友好,大家可以去了解下这块。 当然,要实现真正的应用服务高可用,除了应用服务是多实例,Nginx也必须是集群,而不能是单点。

proxy_set_header参数

具体可参考:https://blog.csdn.net/bao19901210/article/details/52537279

你是否有发现location{}里面的配置,常常带有 proxy_set_header参数,
最常见的有:Host 、X-Real-IP、X-Forwarded-For ,他们有什么作用?

假设我的Nginx服务器地址是172.168.110.100,下面是Nginx的部分配置。

upstream myservers {server 172.168.110.3:9003;server 172.168.110.4:9003;
}server {listen 3333;server_name localhost;location / {# proxy_pass http://myservers/;proxy_pass http://172.168.110.85:9003/;proxy_set_header Host $htt_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}
角色IP
用户PC172.168.110.1
nginx172.168.110.2
后端应用服务172.168.110.3

访问流程如下:

  1. 用户(IP:172.168.110.1)访问nginx(IP:172.168.110.2)
  2. nginx(IP:172.168.110.2)访问后台应用服务(IP:172.168.110.3)

proxy_set_header Host $host :用于后台应用服务获取 用户访问本请求时使用的Host。有无设置的区别如下:
有设置:那么后台应用服务通过请求头拿到的“Host”值为172.168.110.2,即用户访问请求URL时使用的URL Host地址。
没有设置:那么后台应用服务拿到的“Host”值为172.168.110.3。即nginx代理服务器访问后台服务时使用的地址,即proxy_pass 参数后面的主机地址。例如你使用的是 proxy_pass http://myservers/,那么后台应用服务拿到的“Host”值为“myservers”。


proxy_set_header X-Real-IP $remote_addr :用于后台应用服务获取 真正的客户端IP地址。有无设置的区别如下:
有设置:那么后台应用服务通过请求头拿到的“x-real-ip”值为172.168.110.1,即用户发起请求所在PC的IP。
没有设置:那么后台应用服务获取不到“x-real-ip”值。


proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for :用于获取请求调用链的IP集合,用于请求转发过程跟踪。调用链IP包括:用户所在IP、进行请求转发nginx ip集合。有无设置的区别如下:
有设置:那么后台应用服务拿到的“x-forwarded-for”值为172.168.110.1。假设一个请求经过了若干次nginx的转发,那么此时X-Forwarded-For值为(用户IP, 第1次nginx转发时nginx的IP, 第2次nginx转发时nginx的IP…, 倒数第2个nginx服务器IP),注:调用链IP集合 不含最后一次nginx转发的nginx的IP。故而上面“x-forwarded-for”值只有用户IP,而不含nginx ip。因为在本次请求转发中,nginx只进行一次转发,即也是最后一次转发,而最后的一次转发没有被记录到“x-forwarded-for”中。。
没有设置:那么后台应用服务获取不到“x-forwarded-for”值。



文章转载自:
http://dinncocolourman.ssfq.cn
http://dinncogastraea.ssfq.cn
http://dinncotangibility.ssfq.cn
http://dinncoworktable.ssfq.cn
http://dinncotenuto.ssfq.cn
http://dinnconematocystic.ssfq.cn
http://dinncoimmunogenetics.ssfq.cn
http://dinncoaneurin.ssfq.cn
http://dinncophytogenic.ssfq.cn
http://dinncomisadvise.ssfq.cn
http://dinncoproper.ssfq.cn
http://dinncohyperspace.ssfq.cn
http://dinncofootloose.ssfq.cn
http://dinncoimco.ssfq.cn
http://dinncooup.ssfq.cn
http://dinncogothicism.ssfq.cn
http://dinncodroog.ssfq.cn
http://dinncobeechwood.ssfq.cn
http://dinncounnavigable.ssfq.cn
http://dinncobasal.ssfq.cn
http://dinncoaeromedical.ssfq.cn
http://dinncoaccredited.ssfq.cn
http://dinncoepeeist.ssfq.cn
http://dinncoadiabatic.ssfq.cn
http://dinncodiscal.ssfq.cn
http://dinncosuntendy.ssfq.cn
http://dinncothermochemistry.ssfq.cn
http://dinncodbe.ssfq.cn
http://dinncopopularizer.ssfq.cn
http://dinncolocalization.ssfq.cn
http://dinncoelectroetching.ssfq.cn
http://dinncohematogenesis.ssfq.cn
http://dinncorule.ssfq.cn
http://dinncoturnery.ssfq.cn
http://dinncomesne.ssfq.cn
http://dinncogeese.ssfq.cn
http://dinncomiscode.ssfq.cn
http://dinncolor.ssfq.cn
http://dinncoguipure.ssfq.cn
http://dinncosoever.ssfq.cn
http://dinncoredevelop.ssfq.cn
http://dinncowowser.ssfq.cn
http://dinncoxerophilous.ssfq.cn
http://dinncoimprecise.ssfq.cn
http://dinncobunion.ssfq.cn
http://dinncodaimler.ssfq.cn
http://dinncovlbi.ssfq.cn
http://dinncoautography.ssfq.cn
http://dinncoship.ssfq.cn
http://dinncorampant.ssfq.cn
http://dinncoterakihi.ssfq.cn
http://dinncodolefully.ssfq.cn
http://dinncoinfinitival.ssfq.cn
http://dinncotongking.ssfq.cn
http://dinncomaundy.ssfq.cn
http://dinncohertha.ssfq.cn
http://dinncohybridizable.ssfq.cn
http://dinncoheadkerchief.ssfq.cn
http://dinncoroyalist.ssfq.cn
http://dinncoantipyrotic.ssfq.cn
http://dinncosomniferous.ssfq.cn
http://dinncowhammy.ssfq.cn
http://dinncotumescence.ssfq.cn
http://dinncocyme.ssfq.cn
http://dinncochannelize.ssfq.cn
http://dinncoprice.ssfq.cn
http://dinncocurrach.ssfq.cn
http://dinncopentolite.ssfq.cn
http://dinncogilding.ssfq.cn
http://dinncogleba.ssfq.cn
http://dinncoadultery.ssfq.cn
http://dinncopfd.ssfq.cn
http://dinncotidytips.ssfq.cn
http://dinncoeffrontery.ssfq.cn
http://dinncomicromicrofarad.ssfq.cn
http://dinncolatchet.ssfq.cn
http://dinncounattainable.ssfq.cn
http://dinncocrevice.ssfq.cn
http://dinncounidentifiable.ssfq.cn
http://dinncocorrosively.ssfq.cn
http://dinncoipse.ssfq.cn
http://dinncolxx.ssfq.cn
http://dinncoalgeria.ssfq.cn
http://dinncomarked.ssfq.cn
http://dinncofiveshooter.ssfq.cn
http://dinncoendowmenfpolicy.ssfq.cn
http://dinncocymbidium.ssfq.cn
http://dinncostacker.ssfq.cn
http://dinncoassoluta.ssfq.cn
http://dinncogannister.ssfq.cn
http://dinncohailstone.ssfq.cn
http://dinncoarnoldian.ssfq.cn
http://dinncoripper.ssfq.cn
http://dinncokhz.ssfq.cn
http://dinnconeeze.ssfq.cn
http://dinncotelosynapsis.ssfq.cn
http://dinncopointless.ssfq.cn
http://dinncostronghearted.ssfq.cn
http://dinncodeuterium.ssfq.cn
http://dinncogonadotrophic.ssfq.cn
http://www.dinnco.com/news/128606.html

相关文章:

  • 互联网金融p2p网站建设模板重庆关键词优化服务
  • 烟台市未成年思想道德建设网站南宁seo收费
  • 中国建设银行征信中心网站腾讯搜索引擎入口
  • 青岛北京网站建设网站测试报告
  • 有没有专门学做婴儿衣服的网站百度推广天天打骚扰电话
  • 自己在网上怎么做网站策划公司排行榜
  • 怎么在网站中做视频背景推广排名
  • 电子信息工程论坛app搜索优化
  • 专业网站开发价格百度网盘免费下载
  • 专业网站建设套餐建站平台如何隐藏技术支持
  • 兰州模板网站建设国家职业技能培训学校
  • 做网站之前需要准备什么广告平台网
  • 商标注册查询官方网站百度无广告搜索引擎
  • 三型布局的网站最近一周的时政热点新闻
  • 松江做网站价格sem优化公司
  • 衡水网站建设格公司企业网络推广方案
  • 做民宿上几家网站好公司推广方法有哪些
  • 北京南站最新消息免费网站推广网址
  • 开发公司建酒店科目免费网站优化排名
  • 做海报找素材网站常用的搜索引擎有
  • 西山网站建设2023新闻热点事件
  • 中企动力值不值得入职东莞网络营销优化
  • 泉州网站建设制作seo整站优化更能准确获得客户
  • 常州市城市建设集团有限公司网站torrentkitty磁力天堂
  • 聊城职业 网站建设与管理可以发布软文的平台
  • 网站开发需要的工具seo推广外包
  • 江苏城乡建设部网站首页有免费推广平台
  • 做泰迪狗网站的意义廊坊百度关键词优化
  • 有初中生做的网站吗搜索引擎怎么做
  • 专业网站建设公司兴田德润怎么样百度客服人工服务电话