大网数据广告活动
服务器运维问答

HaProxy randomly returning 503 for static files when servers are available

· 52CE 我爱测

HaProxy is randomly returning 503 even though there definitely are backend servers available. The backend is serving the files correctly, as it's access log shows it always returning a 200 or 304. I'm scratching my head why this …

问题原文

原帖链接 · Jonathan S. Fisher · CC BY-SA 4.0

HaProxy is randomly returning 503 even though there definitely are backend servers available. The backend is serving the files correctly, as it's access log shows it always returning a 200 or 304. I'm scratching my head why this is happening. The weirdist thing is it's only happening on this css file!

Example 503 Log Message:

Oct 3 17:26:24 haproxy0-1 haproxy[2313]: x.x.x.x:53265 [03/Oct/2018:17:26:24.187] https-in~ appName/apps-1.prod.companyName.com 0/0/-1/-1/1 503 213 - - CC-- 22/22/16/8/0 0/0 {|} "GET /appName/resources/css/appName.css HTTP/1.1"

HaProxy config:

global
    log /dev/log    local0
    log /dev/log    local1 notice
    chroot /var/lib/haproxy
    stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
    stats timeout 30s
    user haproxy
    group haproxy
    daemon
    ca-base /etc/ssl/certs
    crt-base /etc/ssl/private
    ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS:!AES256
    ssl-default-bind-options force-tlsv12
    tune.ssl.default-dh-param 2048
    lua-load /etc/haproxy/cors.lua

defaults
    log global
    mode http
    option forwardfor
    option httplog
    option dontlognull
    option redispatch
    retries 3
    timeout http-request 20000
    timeout queue 20000
    timeout connect 20000
    timeout client 20000
    timeout server 20000
    timeout http-keep-alive 20000
    timeout check 500
    maxconn 3000
    errorfile 400 /etc/haproxy/errors/400.http
    errorfile 403 /etc/haproxy/errors/403.http
    errorfile 408 /etc/haproxy/errors/408.http
    errorfile 500 /etc/haproxy/errors/500.http
    errorfile 502 /etc/haproxy/errors/502.http
    errorfile 503 /etc/haproxy/errors/503.http
    errorfile 504 /etc/haproxy/errors/504.http

frontend https-in
    bind :443 ssl crt /etc/ssl/private/prod.companyName.com.pem alpn h2,http/1.1
    capture request header origin len 128
    capture request header access-control-request-headers len 128
    http-response set-header Access-Control-Allow-Origin %[capture.req.hdr(0)] if !METH_OPTIONS { capture.req.hdr(0) -m reg -f /etc/haproxy/cors-origins.lst }
    http-request use-service lua.cors-response if METH_OPTIONS { capture.req.hdr(0) -m reg -f /etc/haproxy/cors-origins.lst }
    acl acl_appName path_beg /appName if !METH_OPTIONS
    use_backend appName if acl_appName
    default_backend no-match

backend appName
    reqadd X-Forwarded-Proto:\ https
    balance leastconn
    option httpchk GET /appName/haproxy.jsp HTTP/1.0
    server apps-1.prod.companyName.com apps-1.prod.companyName.com:8443 check ssl verify required ca-file /usr/local/share/ca-certificates/companyName-CA.crt
    server apps-3.prod.companyName.com apps-3.prod.companyName.com:8443 check ssl verify required ca-file /usr/local/share/ca-certificates/companyName-CA.crt

backend no-match
    http-request deny deny_status 404

listen stats
    bind localhost:9000
    mode http
    stats enable
    stats realm Haproxy\ Statistics
    stats uri /stats
    #stats admin if TRUE

Thank you for any help!

已采纳解答

原帖链接 · acritox · CC BY-SA 4.0

Those are probably requests from Firefox with RCWN ("Race Cache With Network") enabled:

"CC--" shows that the client aborted before the connection could be established to the backend-server, which happens when Firefox sends the HTTP request to haproxy and then immediately closes the connection (because it found the response in its cache).

Firefox nsHttpChannel.cpp:

// We will attempt to race the network vs the cache if we've found
// this entry in the cache index, and it has appropriate attributes
// (doesn't have alt-data, and has a small size)

See also about:networking#rcwn (on Firefox)

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-10-03)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。