如何修改nginx默認(rèn)的名稱,可以稍微的偽裝一下,也可以裝x
一般來(lái)說(shuō)修改3個(gè)位置,一個(gè)是nginx.h、另一個(gè)是ngx_http_header_filter_module.c、還有一個(gè)ngx_http_special_response.c。
提示:一般修改都是在nginx編譯之前修改,修改完了之后需要重新編譯
復(fù)制代碼 代碼如下:
scr/core/nginx.conf
#define NGINX_VERSION "1.4.7"
#define NGINX_VER "nginx/" NGINX_VERSION
修改為:(其實(shí)版本號(hào)也可以隨意修改)
復(fù)制代碼 代碼如下:
#define NGINX_VERSION "1.4.7"
#define NGINX_VER "jdws/" NGINX_VERSION
其實(shí)修改上面一個(gè)大部分就會(huì)生效?。?!
復(fù)制代碼 代碼如下:
/src/http/ngx_http_header_filter_module.c (HTTP ResponseHeader)
static char ngx_http_server_string[] = "Server: nginx" CRLF;
修改為:
復(fù)制代碼 代碼如下:
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
修改為:
復(fù)制代碼 代碼如下:
static u_char ngx_http_error_tail[] =
"<hr><center>jdws</center>" CRLF
"</body>" CRLF
"</html>" CRLF
除了隨意修改版本號(hào)之外,還可以隱藏版本號(hào):
修改nginx.conf
在http{}加入
復(fù)制代碼 代碼如下:
http{
server_tokens off;
}
就可以隱藏版本號(hào)了。
注意:
關(guān)掉了server_tokens之后,nginx.conf配置的東西會(huì)無(wú)效,回去尋找剛才我們第二步和第三步的配置
未隱藏版本號(hào):

隱藏版本號(hào):

以上所述是小編給大家介紹的如何修改Nginx版本名稱偽裝任意web server ,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)VEVB武林網(wǎng)網(wǎng)站的支持!