zoukankan      html  css  js  c++  java
  • 修改或隐藏Nginx的版本号

    隐藏版本号

        隐藏nginx的版本号很简单,nginxHttpCoreModule提供了一条叫做server_tokens指令,我这要将这条指令设置为“server_tokens off”就可以了。

    首先访问一下,看一下现有的版本:

    root@ mail ~]# curl --head http://192.168.3.139
    HTTP/1.1 403 Forbidden
    Server: nginx/0.8.53
    Date: Thu, 09 Dec 2010 00:02:04 GMT
    Content-Type: text/html
    Content-Length: 169
    Connection: keep-alive

    通过访问我得到的是“Server: nginx/0.8.53”。

    然后在配置文件中,http区段中插入“server_tokens  off;”,重新载入配置文件:

    root@mail ~]# vi /usr/local/nginx0.8/conf/nginx.conf
     
    worker_processes  1;
     
    events {
        worker_connections  1024;
    }
     
    http {
        include       mime.types;
        default_type  application/octet-stream;
        server_tokens  off;
        expires         5s;
        sendfile        on;
     
        keepalive_timeout  65;
     
    include     "sites-enabled/mail*";
     
    }
    [root@mail ~]#service nginx reload

    修改版本号

        修改版本号的方法可要比隐藏版本号的方法复杂一点,它需要在配置安装nginx之前进行。下载完成nginx并解压后,首先要对源码进行修改,源码文件都在二级目录“nginx-0.8.53/src/”下,找到如下文件“src/core/nginx.h”,然后再对它进行修改,按照下面的代码中指出的两行(以用粗体标明):

    root@mail nginx-0.8.53]# vi src/core/nginx.h
     
    #define nginx_version         8053
    #define NGINX_VERSION      "10.0"
    #define NGINX_VER          "jh/" NGINX_VERSION
     
    #define NGINX_VAR          "NGINX"
    #define NGX_OLDPID_EXT     ".oldbin"
     
     
    #endif /* _NGINX_H_INCLUDED_ */
  • 相关阅读:
    ASP.NET登录记住用户名
    .NET枚举类型转为List类型
    display:inline-block 去除间隙
    sublime text 3 常用快捷键 、常用插件
    使用背景图代码
    Photo Shop 修改、维护
    前端协作流程
    Photo Shop切图
    Photo Shop 设置
    Flex 弹性布局
  • 原文地址:https://www.cnblogs.com/tl542475736/p/5504074.html
Copyright © 2011-2022 走看看