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

combine ACLs in use_backend statement

· 52CE 我爱测

I want to combine 2 different types of acl in haproxy ( src and path_beg ) to make a decision about which backend to use. I tried the following which is not valid syntax: acl my_ip src 192.168.0.50 acl api_path path_beg /api use_…

问题原文

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

I want to combine 2 different types of acl in haproxy (src and path_beg) to make a decision about which backend to use.

I tried the following which is not valid syntax:

acl my_ip src 192.168.0.50
acl api_path path_beg /api
use_backend private_backend if my_ip AND api_path
use_backend public_backend if api_path

The AND in the 3rd line does not work.

I've also tried the following which is not valid syntax:

acl my_ip_and_api_path src 192.168.0.50 path_beg /api

Using path_beg after the src and the IP doesn't work.

已采纳解答

原帖链接 · Mick Switser · CC BY-SA 3.0

Please make sure that the IP address you are connecting from is indeed the mentioned 192.168.0.50 and it's better to note single IP's with a /32 range. Also, remove the AND in the if statement. It is implicit and is known to cause some invalid syntax in some cases if used. So a working configuration for you should be:

acl my_ip src 192.168.0.50/32
acl api_path path_beg /api
use_backend private_backend if my_ip api_path
use_backend public_backend if api_path

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

资料来源与适用范围

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

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

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