預設 expose_php = On 會在 HTTP 回應標頭洩露 PHP 版本:
HTTP/1.1 200 OK
Server: nginx
X-Powered-By: PHP/7.0.10
Content-Type: text/html; charset=UTF-8
攻擊者可針對特定版本漏洞發起精準攻擊。
vi /etc/php.ini(或 /etc/php.d/security.ini)expose_php 設為 Off:
expose_php = Off
systemctl restart httpd 或 systemctl restart php-fpmcurl -I https://example.com/
# 確認不再出現 X-Powered-By 標頭
# /etc/httpd/conf/httpd.conf
ServerTokens Prod
ServerSignature Off
# /etc/nginx/nginx.conf (http 區塊)
server_tokens off;
expose_php、ServerTokens、server_tokens 納入基線檢查清單