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

HAProxy: multiple frontends, same bind

· 52CE 我爱测

Is this possible / correct to configure multiple frontends that binds to the same port on HAProxy? frontend A bind :80 bind :2000-5000 acl rule_about_A use_backend server_A if rule_about_A frontend B bind :80 acl rule_about_B use…

问题原文

原帖链接 · JonDoe297 · CC BY-SA 3.0

Is this possible / correct to configure multiple frontends that binds to the same port on HAProxy?

frontend A
    bind :80
    bind :2000-5000
    acl rule_about_A
    use_backend server_A if rule_about_A

frontend B
    bind :80
    acl rule_about_B
    use_backend server_B if rule_about_B

In this use case, the frontend A needs to bind to 80 and to the range 2000-5000. For the frontend B, I don't want to bind it to all of those ports, only to 80.

I thought it would looks clean if I configure it in that way, instead use a single frontend and play with the ACLs, but it seems like that configuration is making HAProxy works wrong - sometimes applies the correct rule and sometimes, not.

Before to join those frontends as a single one, is it possible to use multiple frontends that bind to same ports?

EDIT: BTW, I'm using HAProxy 1.5

已采纳解答

原帖链接 · Michael - sqlbot · CC BY-SA 3.0

No, you can't do this and expect sensible behavior.

The requests for port 80 will arrive seemingly randomly at one front end or the other. The result of such a configuration is undefined, and though not technically i valid, it is for all practical purposes a nonsensical configuration.

All of the rules applying on port 80 (or any port) need to be specified on a single frontend (or a single listen) that is bound to port 80.

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

资料来源与适用范围

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

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

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