欧卡2中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

需要三步,才能开始

只需两步,慢速开始

欧卡2入门方向盘选莱仕达V9莱仕达折叠便携游戏方向盘支架欢迎地图Mod入驻
查看: 7306|回复: 1
收起左侧

[开源] proxy_upstream_tries

[复制链接]
oppo 发表于 2016-1-12 11:08 | 显示全部楼层 |阅读模式
本帖最后由 oppo 于 2016-1-12 11:47 编辑

只配置proxy_upstream_tries

proxy_upstream_tries 3;

不转移 500,502,503,504

10.0.0.10 [2016-01-12T11:33:16+08:00]  504 584 "GET / HTTP/1.1" "-" "curl" "-" "0.002" "up.204:49309" "504" "0.002"
10.0.0.10 [2016-01-12T11:33:17+08:00]  500 537 "GET / HTTP/1.1" "-" "curl" "-" "0.002" "up.157:49180" "500" "0.002"
10.0.0.10 [2016-01-12T10:56:37+08:00]  503 614 "GET / HTTP/1.1" "-" "curl" "-" "0.003" "up.204:49309" "503" "0.003"
10.0.0.10 [2016-01-12T11:33:49+08:00]  502 681 "GET / HTTP/1.1" "-" "curl" "-" "0.001" "up.204:49309" "502" "0.001"

配合proxy_next_upstream,可以实现5xx故障转移并且控制转移次数

    proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
    proxy_upstream_tries 2;

已负载2个后端,仍然没有得到正确响应码,直接返回后一个后端的状态码

10.0.0.10 [2016-01-12T11:37:58+08:00]  500 732 "GET / HTTP/1.1" "-" "curl" "-" "0.002" "up.204:49309, up.157:49180" "502, 500" "0.001, 0.001"

负载2个后端,返回200

10.0.0.10 [2016-01-12T11:37:53+08:00]  200 10224 "GET / HTTP/1.1" "-" "curl" "-" "0.011" "up.204:49309, up.157:49181" "502, 200" "0.001, 0.010"
 楼主| oppo 发表于 2016-1-12 12:11 | 显示全部楼层
proxy_next_upstream配置了http_503, http_504, 当有后端返回503或者504时,nginx前端access.log记录的都是502:

10.2.6.12 [2016-01-12T12:02:36+08:00]  502 681 "GET / HTTP/1.1" "-" "curl" "-" "0.003" "up-157:49180, up-204:49309" "502, 502" "0.001, 0.002"
up-157请求失败,显示为502, up-204返回的是504,显示依然为502,这样是正常的吗?

nginx版本:
Tengine version: Tengine/2.1.1 (nginx/1.6.2)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

联系我们|手机版|欧卡2中国 ( 湘ICP备11020288号-1 )

GMT+8, 2024-11-25 11:42 , Processed in 0.037123 second(s), 9 queries , Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表