隐藏nginx版本号
1、下载nginx源
rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
2、安装
yum install nginx
3、修改端口
vi /etc/nginx/conf.d/default.conf
改端口成8081
server {
listen 8081;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
4、查看版本号
[root@localhost conf.d]# curl -I localhost:8081
HTTP/1.1 200 OK
Server: nginx/1.16.0
Date: Sun, 07 Jul 2019 09:23:15 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 23 Apr 2019 14:36:26 GMT
Connection: keep-alive
ETag: "5cbf22ea-264"
Accept-Ranges: bytes
5、隐藏版本号
找到nginx.conf
文件
[root@localhost nginx]# find / -name nginx.conf
/etc/nginx/nginx.conf
vim /etc/nginx/nginx.conf
http内容中添加一行
server_tokens off
6、重新加载
systemctl reload nginx
7、再次查看版本号
[root@localhost nginx]# curl -I localhost:8081
HTTP/1.1 200 OK
Server: nginx
Date: Sun, 07 Jul 2019 09:32:36 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 23 Apr 2019 14:36:26 GMT
Connection: keep-alive
ETag: "5cbf22ea-264"
Accept-Ranges: bytes
还没有评论,来说两句吧...