我想从一台服务器迁移100多个站点到另一台服务器。 目前的计划是逐渐添加一个acl,因为他们被移动到一个新的服务器引导stream量。
这是一个简单的例子
front http_frontend bind *:80 acl is_new hdr_end(host) -i sub1.domain.com acl is_new hdr_end(host) -i sub2.domain.com acl is_new hdr_end(host) -i www.domain2.com mode http # etc use_backend web1 if is_new default_backend legacy1
一旦它们全部移动,我们将改变default_backend
有没有办法从另一个文件读取这些acls? 或者从文件中读取域名 – 可能是这样的?
acl is_new hdr_end(host) -i /path/to/file
比如,我把下面所有的安全证书都包括进去了,这样的事情会很棒!
bind *:443 ssl crt /etc/haproxy/certs.d
这不是世界末日,如果不是的话,它会很好,整齐:)。
haproxy中的ACL可以使用-f
参数来加载文件中的值。 你可以在这里阅读文档 。
例如:
acl valid-ua hdr(user-agent) -f exact-ua.lst -i -f generic-ua.lst test
“-f”标志后面跟着一个文件的名字,所有行将作为单独的值读取。 如果要从多个文件加载模式,甚至可以传递多个“-f”参数。 空行以及以锐利('#')开头的行将被忽略。