隱藏版本號
- 正常我們的nginx中的版本號都是正常顯示的,但是這樣容易收到針對版本弱點的攻擊,所以這裏我們將其版本號隱藏。
這是正常情況下的顯示
修改版本配置
vim /usr/local/nginx/conf/nginx.conf
http {
include mime.types;
default_type application/octet-stream;
server_tokens off; #添加,關閉版本號
......
}
重啓服務
systemctl restart nginx.service
查看版本號
-
再次進入,查看版本號,發現只剩下nginx了
-
或者我們通過命令的方式也能夠進行查看
curl -I http://192.168.199.40
修改版本號
- 我們還可以通過修改版本號的方式來進行掩蓋
修改配置文件
vim /opt/nginx-1.12.0/src/core/nginx.h
#define NGINX_VERSION "1.1.1" #修改版本號
#define NGINX_VER "IIS" NGINX_VERSION #修改服務器類型
重新編譯
cd /opt/nginx-1.12.0/
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module
make && make install
vim /usr/local/nginx/conf/nginx.conf
http {
include mime.types;
default_type application/octet-stream;
server_tokens on;
......
}
重啓服務並查看版本號
- 這時候我們發現版本號已經更改成我們自己所設置的版本了
cd /opt/nginx-1.12.0/
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module
make && make install
vim /usr/local/nginx/conf/nginx.conf
http {
include mime.types;
default_type application/octet-stream;
server_tokens on;
......
}