隱藏 Nginx Web Server 版本

Nginx Web Server 在找不到預設首頁時,會出現如下的圖

畫面上會出現使用的 Web Server 種類及版本[@more@]隱藏方式:CentOS 7.x
1. 先備份原設定檔
# cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.$(date +%F)

2. 在 nginx.conf  設定檔中加入 server_tokens off; 設定
# /bin/sed -i ‘/root         /usr/share/nginx/html;/a        server_tokens off;’ /etc/nginx/nginx.conf

3. 重新啟動 Nginx Web Server
# systemctl restart nginx

4. 就不會再出現版本號碼了,但還是會出現 Web Server 種類,想到的解決方式可能是把 404 網頁換掉