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

Ignore port numbers in haproxy host header matches

· 52CE 我爱测

Using haproxy-1.5, I have the following partial config: acl is_api hdr(host) -i api.example.com acl is_app hdr(host) -i app.example.com Unfortunately, the above doesn't match a request that looks like: GET / HTTP/1.1 Host: api.ex…

问题原文

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

Using haproxy-1.5, I have the following partial config:

    acl is_api hdr(host) -i api.example.com
    acl is_app hdr(host) -i app.example.com

Unfortunately, the above doesn't match a request that looks like:

GET / HTTP/1.1
Host: api.example.com:80

Far as I can tell, I need to do:

    acl is_api hdr(host) -i api.example.com
    acl is_api hdr(host) -i api.example.com:80
    acl is_app hdr(host) -i app.example.com
    acl is_app hdr(host) -i app.example.com:80

UGH. NO! HATE!

Is there a nicer way of doing this? Can I just tell haproxy to ignore the port in the host header?

社区高分解答

原帖链接 · Paul Kroon · CC BY-SA 3.0

You might be able to get this to work by checking hdr_dom (https://code.google.com/p/haproxy-docs/wiki/MatchingLayer7) instead of hdr:

acl is_api hdr_dom(host) -i api.example.com
acl is_app hdr_dom(host) -i app.example.com

Just be careful because I believe this would also match things like "otherstuff.api.example.com".

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

资料来源与适用范围

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

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

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