HAProxy 解析錯誤

HAProxy 解析錯誤

我有 3 台伺服器

--> haproxy - server1(uk)
            - server2(ru)

我跟著本教程並為 ru.subnets 建立 ip

現在在我的 /etc/haproxy 中有這些檔案:

haproxy.conf
ru.subnets

在我的 haproxy.conf 中:

frontend http-frontend
    bind  *:80
    mode http
    reqadd X-Forwarded-Proto:\ http

    acl blog_acl path_beg /wp-admin

    acl ru_acl  src -f  RU.subnets

   use_backend wwwru  if ru_acl
    use_backend wwwbackend if !ru_acl

    use_backend wwwru  if blog_acl

    default_backend wwwbackend

一切看起來都不錯,但是當我嘗試在我的 haproxy 中載入設定檔時,我收到以下錯誤:

[ALERT] 170/084453 (4661) : parsing [/etc/haproxy/haproxy.cfg:37] : error detected while parsing ACL 'ru_acl'.
[ALERT] 170/084453 (4661) : parsing [/etc/haproxy/haproxy.cfg:39] : error detected while parsing switching rule.
[ALERT] 170/084453 (4661) : parsing [/etc/haproxy/haproxy.cfg:40] : error detected while parsing switching rule.
[ALERT] 170/084453 (4661) : Error(s) found in configuration file : /etc/haproxy/haproxy.cfg
[ALERT] 170/084453 (4661) : Fatal errors found in configuration.

答案1

試試這個:-)

frontend http-frontend
    bind  *:80
    mode http
    reqadd X-Forwarded-Proto:\ http

    acl blog_acl path_beg /wp-admin

    use_backend wwwru  if { src -f RU.subnets }
    use_backend wwwbackend { src -f RU.subnets }

    use_backend wwwru  if blog_acl

    default_backend wwwbackend

相關內容