如何修改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配置的東西會無效,回去尋找剛才我們第二步和第三步的配置
未隱藏版本號:

隱藏版本號:

以上所述是小編給大家介紹的如何修改Nginx版本名稱偽裝任意web server ,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對VEVB武林網網站的支持!