LoginSignup
1
1

More than 5 years have passed since last update.

404や503発生時にHaproxyから静的ファイルを返す方法メモ

Posted at

参考記事
HOWTO use haproxy custom 503 error document when back server sends 503 http code

Haproxy Documentation

 
やり方としては、haproxy.confのdefaultセクション等にステータスコードごとに表示したいファイルのパスを書くだけです。
(defaults,frontend,listen,backendセクションにかけるようです)

haproxy.conf
defaults
    errorfile 404 /etc/haproxy/errors/404.http
    errorfile 503 /etc/haproxy/errors/503.http
503.http
HTTP/1.0 503 Service Unavailable
Cache-Control: no-cache
Connection: close
Content-Type: text/html

<!DOCTYPE HTML>
<html lang="ja">
    <head>
        <meta charset="utf-8">
        </meta>
    </head>
    <body>
        hogehoge
    </body>
</html>

ファイルの内容を変更した場合は、restartしないと反映されません。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1