Pyhaproxy作业未在“frontend”定义中指定主机和端口

2024-05-18 09:39:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我的pyhaproxy脚本有点小问题,我希望你能引导我朝着正确的方向前进

我的haproxy.cfg包含两个前端

frontend http
    bind 0.0.0.0:80
    acl test_site1 hdr(host) -i test_site1.local
    use_backend test_site1_back if test_site1
    etc. etc.

frontend https
    bind 0.0.0.0:443 ssl crt /etc/ssl/private
    option forwardfor
    reqadd X-Forwarded-Proto:\ https
    acl test_site1 hdr(host) -i test_site1.local
    use_backend test_site1_back if test_site1
    etc. etc.

haproxy很好用-没问题

我的pyhaproxy清理脚本的一部分如下所示:

haproxy_cfg = '/etc/haproxy.cfg'
haproxy_bak = '/etc/haproxy.bak'

parser = Parser(haproxy_cfg)
configuration = parser.build_configuration()
frontends = configuration.frontends
backends = configuration.backends

它给出以下错误消息:[287行is configuration=parser.build\u configuration()]

Traceback (most recent call last): File "./cleaner.py", line 287, in configuration = parser.build_configuration()

File "/a-lot-of-folders/python2.7/site-packages/pyhaproxy/parse.py", line 41, in build_configuration

self.build_frontend(section_node))

File "/a-lot-of-folders/python2.7/site-packages/pyhaproxy/parse.py", line 203, in build_frontend

'Not specify host and port in frontend definition')

Exception: Not specify host and port in frontend definition

Segmentation fault

我做错了什么或错过了什么

问候-拉尔斯


Tags: inpytestbuildhostparserlineetc