【问题标题】:Haproxy multi-line configHaproxy 多行配置
【发布时间】:2021-08-20 23:03:29
【问题描述】:

是否可以将配置参数(在haproxy.cfg 中)拆分为多行?

示例

当前

frontend
     https-in bind :443 ssl strict-sni crt </path/to/cert1.pem> crt </path/to/cert2.pem> crt </path/to/cert3.pem> ...

理想

frontend 
    https-in bind :443 ssl strict-sni
        crt </path/to/cert1.pem>
        crt </path/to/cert2.pem>
        crt </path/to/cert3.pem>
        ...

尝试理想时出错

$ /usr/sbin/haproxy -c -V -f /etc/haproxy/haproxy.cfg
[ALERT] 343/210133 (25646) : parsing [/etc/haproxy/haproxy.cfg:45] : unknown keyword 'crt' in 'frontend' section
[ALERT] 343/210133 (25646) : Error(s) found in configuration file : /etc/haproxy/haproxy.cfg
[ALERT] 343/210133 (25646) : Fatal errors found in configuration.

【问题讨论】:

  • 分割线遇到什么问题?
  • @JeroenHeier 我收到此错误:[ALERT] 343/210133 (25646):解析 [/etc/haproxy/haproxy.cfg:45]:“前端”部分中的未知关键字“crt”
  • (编辑)向问题添加了 configtest 输出。
  • 你是如何生成配置文件的?如果这些方法允许您可以从生成代码中的变量或类似内容进行填充,以便更轻松地编写配置。例如,我们通过厨师食谱生成配置,因此不直接在 haproxy.cfg 中设置任何内容,而是通过变量。
  • 您可以将crt-list 文件名与所有证书路径一起使用。它会很干净。

标签: haproxy


【解决方案1】:

您不能在 haproxy.cfg 中执行多行语法。

查看文件格式文档:https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#2.1

更新:

感谢Venky 的评论,我看到还有使用crt-list 的选项,它确实为多行pem 文件引用提供了一个选项。 https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#5.1-crt-list

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-29
    • 2012-05-19
    • 2020-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多