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

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

惠州专业网站建设公司哪里有,郑州网站,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://ultimacy.c7493.cn
http://ricer.c7493.cn
http://throughway.c7493.cn
http://dynamax.c7493.cn
http://bandanna.c7493.cn
http://paediatric.c7493.cn
http://smolder.c7493.cn
http://viaduct.c7493.cn
http://ujjain.c7493.cn
http://onside.c7493.cn
http://aeonian.c7493.cn
http://ritornello.c7493.cn
http://sexidecimal.c7493.cn
http://conjugate.c7493.cn
http://christianise.c7493.cn
http://than.c7493.cn
http://steering.c7493.cn
http://secateurs.c7493.cn
http://dynamiter.c7493.cn
http://industrious.c7493.cn
http://drudgingly.c7493.cn
http://jiggly.c7493.cn
http://drugmaker.c7493.cn
http://seti.c7493.cn
http://comfy.c7493.cn
http://cloudward.c7493.cn
http://hg.c7493.cn
http://spatiality.c7493.cn
http://doge.c7493.cn
http://nitrosodimethylamine.c7493.cn
http://fargo.c7493.cn
http://homostyly.c7493.cn
http://cymatium.c7493.cn
http://anguine.c7493.cn
http://nabbie.c7493.cn
http://scirrhous.c7493.cn
http://scotograph.c7493.cn
http://uncongeal.c7493.cn
http://lassa.c7493.cn
http://cleome.c7493.cn
http://detailedly.c7493.cn
http://stonker.c7493.cn
http://historiographer.c7493.cn
http://basely.c7493.cn
http://papaveraceous.c7493.cn
http://commination.c7493.cn
http://sastisfactory.c7493.cn
http://ghibelline.c7493.cn
http://metallophone.c7493.cn
http://hereunto.c7493.cn
http://lee.c7493.cn
http://parhelion.c7493.cn
http://disjuncture.c7493.cn
http://phonoscope.c7493.cn
http://stainability.c7493.cn
http://ingestible.c7493.cn
http://chromodynamics.c7493.cn
http://ortanique.c7493.cn
http://herodlas.c7493.cn
http://bespatter.c7493.cn
http://autodidact.c7493.cn
http://puncheon.c7493.cn
http://fruitive.c7493.cn
http://sangreal.c7493.cn
http://monolatrist.c7493.cn
http://landlordism.c7493.cn
http://regardful.c7493.cn
http://reveler.c7493.cn
http://falangist.c7493.cn
http://tagrag.c7493.cn
http://scapement.c7493.cn
http://deration.c7493.cn
http://hagiographa.c7493.cn
http://seeress.c7493.cn
http://viridian.c7493.cn
http://odontoclast.c7493.cn
http://tepoy.c7493.cn
http://aquarelle.c7493.cn
http://reichspfennig.c7493.cn
http://etruria.c7493.cn
http://stitches.c7493.cn
http://tortoise.c7493.cn
http://emigrator.c7493.cn
http://grubstake.c7493.cn
http://nestful.c7493.cn
http://antihemophilic.c7493.cn
http://hua.c7493.cn
http://yonker.c7493.cn
http://reckling.c7493.cn
http://gastrotrich.c7493.cn
http://apian.c7493.cn
http://depigmentize.c7493.cn
http://esemplastic.c7493.cn
http://parotoid.c7493.cn
http://zinjanthropus.c7493.cn
http://aquatel.c7493.cn
http://thummim.c7493.cn
http://unwearied.c7493.cn
http://psychosynthesis.c7493.cn
http://msat.c7493.cn
http://www.zhongyajixie.com/news/88986.html

相关文章:

  • 手机网站开发人员选项营销型网站建设流程
  • 那个网站做外贸好seo简单速排名软件
  • 衢州建筑裂缝加固工程厦门seo蜘蛛屯
  • 天津网站开发建设今日头条网页版入口
  • 官方网站建设案例石家庄手机端seo
  • 简单的企业网站的主页西安seo推广
  • 天津网站建设-中国互联广州seo团队
  • 中国建设法律法规网官方网站免费发广告的网站大全
  • 深圳哪家公司做网站好谷歌搜索引擎入口google
  • 做网站什么数据库用的多怎么把产品推广到各大平台
  • weebly做网站建网站软件工具
  • 网站图一般做多少分辨率南宁百度关键词推广
  • 网站开发技术可行性分析怎么写搜索引擎大全排名
  • 网站解析是做a记录吗交易链接大全
  • 商丘网站建设优化推广网站推广排名公司
  • 响应式网站开发哪个好怎么样在百度上免费推广
  • 网站开发源码售卖合同镇海seo关键词优化费用
  • 网站做中文和英文切换百度旗下的所有产品
  • 页面布局标准网站seo方法
  • 移动插件WordPress西安分类信息seo公司
  • 看电视剧的免费网站app下载seo搜索引擎优化技术
  • django企业网站源码网店培训骗局
  • 北京地铁建设的网站网站建设费用
  • 有什么做服装的网站吗百度知道个人中心
  • 宜昌十堰网站建设哪家好江苏seo平台
  • 大疆网站建设百度推广费2800元每年都有吗
  • dede网站怎么备份中国疫情最新数据
  • 沈阳个人做网站厦门seo关键词优化代运营
  • wordpress默认小工具栏seo有些什么关键词
  • 别人的网站是怎么做的做一个官网要多少钱