我有将近 200 行 ACL 配置haprox.cfg
,还包含 150 个后端。为了消除这种配置复杂性,我想将此配置捆绑在单独的文件中,并将这些文件导入到haprox.cfg
. 这在haproxy中可能吗?
据我所知,HAproxy 没有任何类似于 apache 的Include & IncludeOptional
指令。
除了使用重复的-f <config-file>
命令行开关启动 HAproxy 之外,没有对多个配置文件的本机支持。看到这个线程。
您可以编写一些脚本来将多个小节合并到一个类似于这种方法的更大文件中,尽管我可能会走这条路并修改init 脚本以自动附加其他配置文件(未经测试):
# Load additional configuration snippets from /etc/haproxy.d/*.cfg
OPTIONS=""
for file in /etc/haproxy.d/*.cfg ; do test -f $file && OPTIONS="$OPTIONS -f $file" ; done
start() {
/usr/sbin/$BASENAME -c -q -f /etc/$BASENAME/$BASENAME.cfg $OPTIONS
if [ $? -ne 0 ]; then
echo "Errors found in configuration file, check it with '$BASENAME check'."
return 1
fi
echo -n "Starting $BASENAME: "
daemon /usr/sbin/$BASENAME -D -f /etc/$BASENAME/$BASENAME.cfg $OPTIONS -p /var/run/$BASENAME.pid
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$BASENAME
return $RETVAL
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
10799 次 |
最近记录: |