![Httpd LimitRequestFieldSize が考慮されていません](https://rvso.com/image/726412/Httpd%20LimitRequestFieldSize%20%E3%81%8C%E8%80%83%E6%85%AE%E3%81%95%E3%82%8C%E3%81%A6%E3%81%84%E3%81%BE%E3%81%9B%E3%82%93.png)
大きな SPNEGO 認証ヘッダーを受け入れるように httpd を構成する際に問題が発生しました。 リクエストは、少なくとも 5674 バイトまでの Authorization ヘッダー行では正常に機能しますが、6178 バイトを超える Authorization ヘッダーでは次の応答で中断されます。
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
Size of a request header field exceeds server limit.</p>
</body></html>
サーバーログに次のエラーが表示されます(デバッグレベル)
[Thu Aug 23 07:26:31 2018] [error] [client x.x.x.x] request failed: error reading the headers
以下は、LimitRequestFieldSizeが十分に高いことを確認するためにアクティブ化したサーバー情報ページの抜粋です。
129: LimitRequestBody 52428800
130: LimitRequestFields 50
131: LimitRequestFieldsize 40960
132: LimitRequestLine 40960
サーバーは標準のhttpdサーバーを搭載したRHEL 6.7を実行しています
$ httpd -V
Server version: Apache/2.2.15 (Unix)
Server built: Mar 3 2015 12:06:14
Server's Module Magic Number: 20051115:25
Server loaded: APR 1.3.9, APR-Util 1.3.9
Compiled using: APR 1.3.9, APR-Util 1.3.9
Architecture: 64-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="run/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
答え1
Apache 2.4 を搭載した Ubuntu 18.04 LTS マシンで、次のファイルを変更しました:
/etc/apache2/conf-available/httpd.conf
ドキュメントによると詳しくは、http://httpd.apache.org/docs/2.4/mod/core.html をご覧ください。
# https://askubuntu.com/questions/340792/size-of-a-request-header-field-exceeds-server-limit-due-to-many-if-none-match-va
# default is 8k see https://httpd.apache.org/docs/2.4/mod/core.html
LimitRequestFieldSize 32768
# default is 100
LimitRequestFields 200
サーバーを再起動します。設定をいじってみるといいかもしれません
答え2
仮想ホストを編集し、リクエスト サイズの制限を確認します。
httpd.h でデフォルト値を確認できます (例: DEFAULT_LIMIT_REQUEST_FIELDSIZE)
例 :
<VirtualHost ...>
ServerName www.mysite.com
...
#HTTP Request
LimitRequestFieldSize 32768
LimitRequestFields 200
LimitXMLRequestBody 0
...
</VirtualHost>
詳細は以下を参照:詳しくはこちら
答え3
LimitRequest ディレクティブをサーバー設定に配置する場合、それらのディレクティブは VirtualHost 設定の前に挿入する必要があります。