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后寫上你自定義的服務(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文章
139瀏覽量
25056 -
nginx
+關(guān)注
關(guān)注
0文章
180瀏覽量
12857
原文標(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)先 登錄
云加速是如何隱藏源服務(wù)器ip的
【VisionFive 2單板計(jì)算機(jī)試用體驗(yàn)】2. 刷機(jī)、同局域網(wǎng)mac訪問(wèn)存放圖片及作為web服務(wù)器
Nginx在企業(yè)環(huán)境中的調(diào)優(yōu)策略
Nginx和Apache的差異
Nginx配置終極指南

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

Nginx基礎(chǔ)安裝與配置教程
Nginx緩存配置詳解

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

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

如何通過(guò)優(yōu)化Nginx配置來(lái)提高網(wǎng)絡(luò)環(huán)境的安全性
華為云彈性云服務(wù)器 FlexusX 實(shí)例下的 Nginx 性能測(cè)試

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

評(píng)論