修改nginx版本名稱偽裝任意web server


如何修改nginx默認的名稱,可以稍微的偽裝一下,也可以裝x

一般來說修改3個位置,一個是nginx.h、另一個是ngx_http_header_filter_module.c、還有一個ngx_http_special_response.c。

提示:一般修改都是在nginx編譯之前修改,修改完了之后需要重新編譯

scr/core/nginx.conf

#define NGINX_VERSION      "1.4.7"
#define NGINX_VER          "nginx/" NGINX_VERSION

修改為:(其實版本號也可以隨意修改)

#define NGINX_VERSION      "1.4.7"
#define NGINX_VER          "jdws/" NGINX_VERSION

其實修改上面一個大部分就會生效!!!

 

/src/http/ngx_http_header_filter_module.c (HTTP ResponseHeader)

static char ngx_http_server_string[] = "Server: nginx" CRLF;

修改為:

static char ngx_http_server_string[] = "Server: jdws" CRLF;

 

/src/http/ngx_http_special_response.c 

static u_char ngx_http_error_tail[] =
"<hr><center>nginx</center>" CRLF
"</body>" CRLF
"</html>" CRLF

修改為:

static u_char ngx_http_error_tail[] =
"<hr><center>jdws</center>" CRLF
"</body>" CRLF
"</html>" CRLF

 

除了隨意修改版本號之外,還可以隱藏版本號:

修改nginx.conf

在http{}加入

http{
     server_tokens  off;  
}

就可以隱藏版本號了。

 

注意:

關掉了server_tokens之后,nginx.conf配置的東西會無效,回去尋找剛才我們第二步和第三步的配置

未隱藏版本號:

隱藏版本號:

基本ok啦啦啦啦

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM