「http-response set-status」を使用するときにhaproxyログステータスコードが200であるのはなぜですか?「?

「http-response set-status」を使用するときにhaproxyログステータスコードが200であるのはなぜですか?「?

私はhaproxy 1.7.8を使用しています。

HTTP Referer ヘッダーの一部の特定の虐待ドメインに対する要求をブロックする構成があります。

私のhaproxy設定の重要な部分は次のとおりです。

 frontend https_l1_xxxxx

    (...)

    acl is_abuser_by_referer capture.req.hdr(7) -m reg -i ^https?:\/\/(.+\.)?(someabuser.com|someabuser2.com|someabuser3.com)(\?.*|\/.*)?$
    acl return_html_path path_beg /urlICareAbout
    use_backend abuser if is_abuser_by_referer return_html_path

 backend abuser

    # override standard 200 status code
    http-response set-status 418 reason "I'm a teapot"
    server nginx_abusers localhost:8091

...nginxは実際に8091を受け取り、いくつかのHTMLを提供します。

動作します。ブラウザ/カールにこのHTTPヘッダを設定し、haproxyに要求してテストしました。 418が表示されました。


問題は、私のhaproxyログが次のようになることです。

Feb 5 13:11:45 aaa-www05 haproxy_l1_xxxxx[38749]: 111.222.111.222:2605 [05/Feb/2018:13:11:44.849] DFDA00BD:0A2D_0A19800C:01BB_--_7BFDAD https_l1_xxxxx ~ abuser/nginx_abusers 280/0/1/0/282 200 6044 - - ---- 145/145/0/0/0 0/0 {e60b039c46a1e104a94558ce0e480654||07.mydomain.com|||Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB7.5; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET4.0C; .NET||http://someabuser.com/player.swf} {||} 467 "GET /urlICareAbout/?preview=true HTTP/1.1"

...ステータスコード200が418の代わりに記録されます。


なぜこれが起こるのですか?


修正する:私はhaproxyが返された実際のステータスコードを記録したいと思います。HTTP ログ形式文書の状態:

- "status_code" is the HTTP status code returned to the client. This status is generally set by the server, but it might also be set by haproxy when the server cannot be reached or when its response is blocked by haproxy.

ベストアンサー1

期待どおりに動作します。バックエンドは記録された状態の200 OKを返します。システム管理者がデバッグ目的でログに実際のバックエンド応答データを必要とするため、これを上書きする必要はありません。

「status_code」は、クライアントに返されたHTTPステータスコードです。

クライアントの状態は418で、Gregが書いたように、これはうまくいきます。

おすすめ記事