nginx不僅可以隱藏版本信息,還支持自定義web服務(wù)器信息
先看看最終的隱藏結(jié)果吧
具體怎么實(shí)現(xiàn)呢,其實(shí)也很簡(jiǎn)單,請(qǐng)往下看
1 官網(wǎng)下載最新穩(wěn)定版
wget http://nginx.org/download/nginx-1.14.1.tar.gz
2 解壓
tar -xf nginx-1.14.1.tar.gz cd nginx-1.14.1
3 修改C文件
(1)vim src/http/ngx_http_header_filter_module.c #修改49行
static u_char ngx_http_server_string[] = "Server: Please guess it!" CRLF; #Server后寫(xiě)上你自定義的服務(wù)器信息
(2)vim src/http/ngx_http_special_response.c #修改36行
"
4 編譯配置
./configure --prefix=/usr/local/nginx
5 編譯安裝
make && make install
6 修改nginx配置文件,http節(jié)點(diǎn)下添加server_tokens off
vim /usr/local/nginx/conf/nginx.conf .... http { server_tokens off; .....
7 啟動(dòng)nginx
/usr/local/nginx/sbin/nginx
8 測(cè)試
[root@node1 nginx-1.14.1]# curl -I http://127.0.0.1 HTTP/1.1 200 OK Server: Please guess it! Date: Wed, 07 Nov 2018 19:15:43 GMT ......
瀏覽器訪問(wèn)測(cè)試
說(shuō)明:(1)要是只想隱藏版本號(hào),而不想自定義服務(wù)器信息,不需要執(zhí)行第3步.
(2)要是對(duì)nginx升級(jí)同時(shí)還要做字符串自定義,也是沒(méi)有問(wèn)題的,可以先修改C文件-->./configure --> make 即可
具體nginx升級(jí)請(qǐng)參考https://www.cnblogs.com/Sunzz/p/9953443.html
鏈接:https://www.cnblogs.com/Sunzz/p/9962891.html
-
Web服務(wù)器
+關(guān)注
關(guān)注
0文章
138瀏覽量
24780 -
nginx
+關(guān)注
關(guān)注
0文章
167瀏覽量
12521
原文標(biāo)題:nginx 隱藏版本號(hào)與WEB服務(wù)器信息
文章出處:【微信號(hào):magedu-Linux,微信公眾號(hào):馬哥Linux運(yùn)維】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。
發(fā)布評(píng)論請(qǐng)先 登錄
Nginx配置終極指南

云原生環(huán)境里Nginx的故障排查思路

Nginx基礎(chǔ)安裝與配置教程
如何配置Linux防火墻和Web服務(wù)器

Nginx緩存配置詳解

【教程】Chirpstack V3服務(wù)器簡(jiǎn)介和搭建示例

Nginx常見(jiàn)面試題總結(jié)

如何通過(guò)優(yōu)化Nginx配置來(lái)提高網(wǎng)絡(luò)環(huán)境的安全性
華為 FlexusX 與 Docker+Nginx 的高效整合之路

華為云彈性云服務(wù)器 FlexusX 實(shí)例下的 Nginx 性能測(cè)試

「服務(wù)器」Nginx Proxy Manager申請(qǐng)cloudflare泛域名

nginx負(fù)載均衡配置介紹

使用NS1串口服務(wù)器HTTP模式上傳服務(wù)器數(shù)據(jù)

評(píng)論