问题原文
原帖链接 · 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
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
