无法读取Haproxy错误文件

时间:2016-12-22 17:44:38

标签: haproxy

我有以下Haproxy配置:

frontend http-in
    mode http
    bind :80

    option forwardfor
    option httplog
    reqadd X-Forwarded-Proto:\ http

    default_backend http-routers

    errorfile 502 /var/haproxy/404.http
    acl is_internal_error status eq 404
    rspdeny . if is_internal_error

当我点击非现有域名的网址时,例如:http://test.example.com 我收到超时错误(408)。

但是,当我检索行errorfile 502 /var/haproxy/404.http时,我可以看到502错误代码的默认错误消息。

有人能说出为什么Haproxy无法读取我的文件/var/haproxy/404.http吗?

2 个答案:

答案 0 :(得分:0)

听起来像是权限问题。什么用户是haproxy运行的?你能发布/var/haproxy/404.http的权限吗?

答案 1 :(得分:0)

我认为这是Haproxy behind ELB的副本。

TL; DR; erro_file换行格式的问题。 您需要在HTTP INFO行上使用^ M,而在响应正文中不需要。 不知道为什么,但它表现得那样。希望能帮助到你。 Example file有在vi(m)中打开的那些。不要复制内容,它看起来一样但不是。

干杯