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

HAProxy: use_backend ignored because backend has no frontend capability

· 52CE 我爱测

I have an HAProxy config file that's being built programmatically and I'm getting an error like the following for every single backend that's defined: [WARNING] 073/153725 (1663) : parsing [/etc/haproxy/haproxy.cfg:964] : 'use_ba…

问题原文

原帖链接 · David Perry · CC BY-SA 3.0

I have an HAProxy config file that's being built programmatically and I'm getting an error like the following for every single backend that's defined:

[WARNING] 073/153725 (1663) : parsing [/etc/haproxy/haproxy.cfg:964] : 'use_backend' ignored because backend 'bk_10716' has no frontend capability.

My config file is fairly straightforward and a simplified version with just one backend seems to work, so I can't put my finger on what's wrong.

My config file consists of this:

global
    tune.ssl.default-dh-param 2048
    log     127.0.0.1 local1 debug
    chroot  /var/lib/haproxy
    user    haproxy
    group   haproxy
    maxconn 4000
    daemon

defaults
    log     global
    mode    http
    option  httplog
    option  dontlognull
    timeout connect 5000
    timeout client 50000
    timeout server 50000
    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

listen stats
    bind *:1234
    stats auth admin:bdi2016
    stats uri /
    stats realm Haproxy\ Statistics
    stats enable
    mode http

frontend http:
    bind *:80
    mode http
    option httpclose
    option forwardfor

followed by a great number of these:

use_backend bk_10011 if { hdr_end(host) -i somedomainname.com }
    backend bk_10011
        server server_10011   127.0.0.1:10011 check

Am I just missing something obvious/stupid?

已采纳解答

原帖链接 · David Perry · CC BY-SA 3.0

It was just a dumb mistake. I needed to specify all of my use_backend if statements within the frontend instead of above each individual backend. This is why it worked with only one backend, because regardless of indentation the first use_backend "belonged" to frontend http: and every subsequent backend appeared orphaned.

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

资料来源与适用范围

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

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

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