隐藏nginx版本号

深藏阁楼爱情的钟 2021-12-14 03:23 341阅读 0赞

1、下载nginx源

  1. rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

2、安装

  1. yum install nginx

3、修改端口

  1. vi /etc/nginx/conf.d/default.conf

改端口成8081

  1. server {
  2. listen 8081;
  3. server_name localhost;
  4. #charset koi8-r;
  5. #access_log /var/log/nginx/host.access.log main;
  6. location / {
  7. root /usr/share/nginx/html;
  8. index index.html index.htm;
  9. }

4、查看版本号

  1. [root@localhost conf.d]# curl -I localhost:8081
  2. HTTP/1.1 200 OK
  3. Server: nginx/1.16.0
  4. Date: Sun, 07 Jul 2019 09:23:15 GMT
  5. Content-Type: text/html
  6. Content-Length: 612
  7. Last-Modified: Tue, 23 Apr 2019 14:36:26 GMT
  8. Connection: keep-alive
  9. ETag: "5cbf22ea-264"
  10. Accept-Ranges: bytes

5、隐藏版本号
找到nginx.conf文件

  1. [root@localhost nginx]# find / -name nginx.conf
  2. /etc/nginx/nginx.conf
  3. vim /etc/nginx/nginx.conf

http内容中添加一行

server_tokens off

6、重新加载

  1. systemctl reload nginx

7、再次查看版本号

  1. [root@localhost nginx]# curl -I localhost:8081
  2. HTTP/1.1 200 OK
  3. Server: nginx
  4. Date: Sun, 07 Jul 2019 09:32:36 GMT
  5. Content-Type: text/html
  6. Content-Length: 612
  7. Last-Modified: Tue, 23 Apr 2019 14:36:26 GMT
  8. Connection: keep-alive
  9. ETag: "5cbf22ea-264"
  10. Accept-Ranges: bytes

发表评论

表情:
评论列表 (有 0 条评论,341人围观)

还没有评论,来说两句吧...

相关阅读

    相关 mysql隐藏版本

    mysql版本更新很快,每个版本都或多或少存在一定的bug,经过安全厂商的扫描会被扫描出,需要我们整改,在同事的启发和帮助下,做了一些测试: (1)解压源码包,调整VERSI

    相关 nginx 隐藏nginx版本

    为什么要隐藏 Nginx 版本号:一般来说,软件的漏洞都与版本有关,隐藏版本号是为了防止恶意用户利用软件漏洞进行攻击 worker\_processes 1; events