TMA-NGINX-2.4.3
Ensure keepalive_timeout is 10 seconds or less, but not 0
説明
Persistent connections are leveraged by all modern browsers to facilitate greater web performance. The keep-alive timeout limits the time a persistent connection may remain open. Setting the keep-alive timeout allows this timeout to be controlled on the server side. Every keepalive_timeout must be between 1 and 10 seconds and the directive must be set (the NGINX default is 75s). Evaluated on the merged configuration printed by `nginx -T` (all included files; needs permission to read them). CIS marks this recommendation Manual; the automated check implements its audit procedure.
チェック方法
監査方法: シェルコマンド
out=$(nginx -T 2>/dev/null) || exit 1; printf '%s\n' "$out" | awk '{l=$0; o=""; q=""; for(i=1;i<=length(l);i++){c=substr(l,i,1); if(q!=""){o=o c; if(c==q) q=""; continue} if(c=="\""||c=="\047"){q=c; o=o c; continue} if(c=="#") break; if(c==";"||c=="{"){print o c; o=""; continue} if(c=="}"){if(o~/[^[:space:]]/) print o; print "}"; o=""; continue} o=o c} if(o~/[^[:space:]]/) print o}' | awk 'function a(i, x){x=$i; sub(/;$/,"",x); gsub(/["\047]/,"",x); return x} function inb(n, i){for(i=1;i<=sp;i++) if(st[i]==n) return 1; return 0} ($1=="keepalive_timeout"){v=a(2); m=1; if(v~/m$/) m=60; sub(/[ms]$/,"",v); seen[$1]=1; if(v*m<1||v*m>10) bad=1} {o=gsub(/\{/,"{"); c=gsub(/\}/,"}"); while(o-->0){sp++; b=$1; sub(/\{.*/,"",b); st[sp]=b} while(c-->0 && sp>0) sp--} END{print (seen["keepalive_timeout"]&&!bad)?"compliant":"noncompliant"}'- 期待される出力
compliant
修正方法
修正方法: ガイダンスまたは IaC パッチ
Set 'keepalive_timeout 10;' in the http block (and any server block that overrides it). Then run nginx -t and reload nginx.
プロパティ
- オペレーティングシステム
- すべて
- タグ
- nginxdos
- 参照
- CIS NGINX Benchmark v3.0.0 - 2.4.3 Ensure keepalive_timeout is 10 seconds or less, but not 0
このホストをチェック
監査が許可されているマシンで実行してください。スキャンは読み取り専用です。
tmaegis scan --target nginx