2016-12-22 92 views
2

我有以下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

回答

0

聽起來像權限問題馬上蝙蝠。 haproxy運行的用戶是什麼?你能發佈/var/haproxy/404.http的權限嗎?

+1

haproxy作爲根運行。我將/var/haproxy/404.http的權限更改爲777(chmod 777)。但它仍然是同樣的問題 –

+0

看起來根本原因是AWS ELB。其實,我有HAproxy是在AWS ELB後面。只要我刪除ELB,我可以得到自定義錯誤頁面。但是,在Haproxy前端的ELB中,我得到'HTTP/1.1 504 GATEWAY_TIMEOUT Content-Length:0 Connection:keep-alive'。任何人都可以告訴我發生了什麼事。謝謝。 –

+0

它解決了這個問題http://stackoverflow.com/questions/43376997/haproxy-behind-elb –

0

我認爲這是Haproxy behind ELB的重複。

TL; DR; erro_file換行格式的問題。 您需要HTTP INFO行上的^ M,而不是響應主體上需要的。 不知道爲什麼,但它表現如此。希望能幫助到你。 Example file有那些在vi(m)打開時。不要複製內容,它看起來一樣但不是。

Cheers