どうも…中一の時の英語教員だった花ティーに文句を言いたいかっぱ、こと川原 洋平(@inokara)です。

はじめに

今度は option httpclose の説明について翻訳してみたいと思います。

かなりピンポイントですが…すいません。全部訳していたら死んでしまいます…。

option httpclose

Enable or disable passive HTTP connection closing

「受動的な HTTP 接続クローズ」に関して有効、無効を設定します。

May be used in sections :

以下のセクションで利用されます。

  • defaults
  • frontend
  • listen
  • backend

By default HAProxy operates in keep-alive mode with regards to persistent connections: for each connection it processes each request and response, and leaves the connection idle on both sides between the end of a response and the start of a new request. This mode may be changed by several options such as “option http-server-close”, “option forceclose”, “option httpclose” or “option http-tunnel”.

デフォルトでは、HAProxyのは、永続的な接続に関しては、keep-alive モードで動作します。各接続は各リクエストとレスポンスを処理し、応答の終わりと新しい要求の開始との間の両側に接続アイドルを残します。このモードは、”option http-server-close” や “option forceclose” や “option httpclose” または “option http-tunnel” などのいくつかのオプションで変更できます。

If “option httpclose” is set, HAProxy will work in HTTP tunnel mode and check if a “Connection: close” header is already set in each direction, and will add one if missing. Each end should react to this by actively closing the TCP connection after each transfer, thus resulting in a switch to the HTTP close mode. Any “Connection” header different from “close” will also be removed. Note that this option is deprecated since what it does is very cheap but not reliable. Using “option http-server-close” or “option forceclose” is strongly recommended instead.

もし “option httpclose” が設定されている場合、HAProxy は HTTP トンネルモードで動作し、それぞれの方向でヘッダに “Connection: close” 設定されているかが確認され、もし設定されていなければ追加されます。各エンドポイントは各転送後に TCP 接続を閉じる “HTTP Close” モードに切り替えて対応する必要があります。任意の “Connection” ヘッダーが異なる “Close” でも削除されます。このオプションは信頼出来ないので代わりに “option http-server-close” や “option forceclose” を利用することを強くお薦めします。

It seldom happens that some servers incorrectly ignore this header and do not close the connection even though they reply “Connection: close”. For this reason, they are not compatible with older HTTP 1.0 browsers. If this happens it is possible to use the “option forceclose” which actively closes the request connection once the server responds. Option “forceclose” also releases the server connection earlier because it does not have to wait for the client to acknowledge it.

それはほとんどのサーバが誤ってこのヘッダが無視されて、”Connection: close” を返信したにも関わらず、接続が閉じないことがあります。その為、古い HTTP 1.0 ブラウザとの互換性がありません。この問題が発生した場合にはサーバーが応答すると積極的に接続要求をクローズする “option forceclose” を使用することが可能です。また、”option forceclose” はクライアントからの接続を待つ必要がない為、以前(以前ってなんや?)のサーバ接続を解放します。

This option may be set both in a frontend and in a backend. It is enabled if at least one of the frontend or backend holding a connection has it enabled. It disables and replaces any previous “option http-server-close”, “option forceclose”, “option http-keep-alive” or “option http-tunnel”. Please check section 4 (“Proxies”) to see how this option combines with others when frontend and backend options differ.

このオプションは frontend および backend の両方で設定できます。接続を保持している frontend または backend の少なくとも一つが有効になっていれば option httpclose が有効です。これは、以前の “option http-keep-alive” や “option forceclose” や “option http-keep-alive” または “option http-tunnel” を無効にし置き換えられます。frontend と backend のオプションが異なる場合、このオプションについて確認するには第 4 セクションの “Proxies” をご確認ください。

ということで…

  • HA Proxy は option httpclose オプションが有効だと HTTP トンネルモードで動作する
  • option httpclose はあんまり使わない方が良さそう…
  • 代わりに “option http-server-close” や “option forceclose” を使う方が良さそう

元記事はこちらです。