haproxy 会有很多随机性的502报错

发布于 2022-09-12 23:54:18 字数 4041 浏览 31 评论 0

haproxy中出现很多的502状态,比较随机,但是同一个请求URL在大部分时候却是好的,状态是200。

并且奇怪的是request_time在大部分的502状态时为0,感觉未曾尝试连接过

{"timestamp":"2021-05-27T13:28:13+08:00","remote_addr":
"101.200.28.###","request_uri":
"/pinsurvey/api/v1/projects/","protocol": "HTTP/1.1","request_method":
"GET","status": "502","body_bytes_sent":
"568","http_x_forwarded_for": "112.103.45.###","http_referer":
"https://servicewechat.com/wx0aa7dbf32636dc01/42/page-frame.html",**"request_time":
"0.000","upstream_response_time": "0.000 :
0.000","upstream_addr": "localhost : localhost","upstream_connect_time": "0.000 :
0.000"**,"http_user_agent": "Mozilla/5.0 (Linux; Android 10; HRY-AL00Ta Build/HONORHRY-AL00Ta; wv) AppleWebKit/537.36 (KHTML, like
Gecko) Version/4.0 Chrome/78.0.3904.62 XWEB/2797 MMWEBSDK/20210302
Mobile Safari/537.36 MMWEBID/7133
MicroMessenger/8.0.3.1880(0x2800033D) Process/appbrand0 WeChat/arm64
Weixin NetType/WIFI Language/zh_CN ABI/arm64 MiniProgramEnv/android"}

以下是正常状态的日志:

{"timestamp":"2021-05-23T11:39:42+08:00","remote_addr": "39.96.151.174","request_uri": "/pinsurvey/api/v1/projects/","protocol": "HTTP/1.1","request_method": "GET","status": "200","body_bytes_sent": "527","http_x_forwarded_for": "61.180.177.186","http_referer": "https://servicewechat.com/wx0aa7dbf32636dddd/40/page-frame.html","request_time": "0.107","upstream_response_time": "0.106","upstream_addr": "127.0.0.1:7879","upstream_connect_time": "0.000","http_user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.5(0x18000529) NetType/WIFI Language/zh_CN"}

我的配置文件:

global
    log         /dev/log local0

    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     30000
    user        haproxy
    group       haproxy
    daemon

    stats socket /var/lib/haproxy/stats


defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000

listen stats                      
    mode  http
    bind  *:7992
    stats refresh 30s
    stats uri /stats              
    stats realm HAProxy Stats

#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend  main
    bind  *:7879
    # ez-admin-api
    acl ez_admin_acl path_beg -i /ez-admin/
    use_backend ez_admin if ez_admin_acl

    # pinsurvey-api
    acl pinsurvey_acl path_beg -i /pinsurvey/
    use_backend pinsurvey if pinsurvey_acl

    # ez-datamanagement-api
    acl ez_datamanagement_acl path_beg -i /ez-datamanagement/
    use_backend ez_datamanagement if ez_datamanagement_acl

    default_backend             ez_admin

backend ez_admin
    http-request replace-path /ez-admin/(.*) /\1
    balance  roundrobin
    server   ez_admin_22 127.0.0.1:7807 check
    server   ez_admin_142 172.17.28.73:7807 check

backend pinsurvey
    http-request replace-path /pinsurvey/(.*) /\1
    balance  roundrobin
    server   pinsurvey_159 172.17.28.66:7878 check
    server   pinsurvey_52 172.17.28.52:7878 check
    server   pinsurvey_124 123.56.241.124:7878 check
    server   pinsurvey_30 182.92.201.30:7878 check
    server   pinsurvey_34 172.17.117.34:7878 check

backend ez_datamanagement
    http-request replace-path /ez-datamanagement/(.*) /\1
    balance  roundrobin
    server   ez_datamanagement_1 192.168.10.219:7801 check

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文