nginx隱藏server及版本號的實現(xiàn)
1、背景
為了提高nginx服務(wù)器的安全性,降低被攻擊的風(fēng)險,需要隱藏nginx的server和版本號。
2、隱藏nginx版本號
在 http {—}里加上 server_tokens off; 如:
http {
……省略
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
server_tokens off;
…….省略
}
3、隱藏server信息
修改源碼文件,從新編譯
# vim /path/nginx/src/http/ngx_http_header_filter_module.c 修改前 49 static u_char ngx_http_server_string[] = "Server: nginx" CRLF; 50 static u_char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF; 51 static u_char ngx_http_server_build_string[] = "Server: " NGINX_VER_BUILD CRLF; 修改后 49 static u_char ngx_http_server_string[] = "Server: " CRLF; 50 static u_char ngx_http_server_full_string[] = "Server: " CRLF; 51 static u_char ngx_http_server_build_string[] = "Server: " CRLF;

4、隱藏 nginx -V 的版本號
修改源碼文件,從新編譯
# vim /path/nginx/src/core/nginx.c
修改前
390 static void
391 ngx_show_version_info(void)
392 {
393 ngx_write_stderr("nginx version: " NGINX_VER_BUILD NGX_LINEFEED);
394
395 if (ngx_show_help) {
修改后
390 static void
391 ngx_show_version_info(void)
392 {
393 ngx_write_stderr("nginx version: " "hello world\n");
394
395 if (ngx_show_help) {

到此這篇關(guān)于nginx隱藏server及版本號的實現(xiàn)的文章就介紹到這了,更多相關(guān)nginx隱藏server及版本號內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
解決nginx+uwsgi部署Django的所有問題(小結(jié))
本篇文章主要介紹了解決nginx+uwsgi部署Django的所有問題(小結(jié)),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-04-04
nginx php-fpm環(huán)境中chroot功能的配置使用方法
這篇文章主要介紹了nginx php-fpm環(huán)境中chroot功能的配置使用方法,此方法是比禁用PHP敏感函數(shù)更好的一個安全防護手手段,需要的朋友可以參考下2014-05-05
Windows環(huán)境下Nginx?服務(wù)器?SSL?證書安裝部署操作過程
這篇文章主要介紹了Windows環(huán)境下Nginx?服務(wù)器?SSL?證書安裝部署,指導(dǎo)您如何在Windows Nginx 服務(wù)器中安裝 SSL 證書,本文給大家講解的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-10-10
Nginx+SpringBoot實現(xiàn)負(fù)載均衡的示例
這篇文章主要介紹了Nginx優(yōu)雅的實現(xiàn)負(fù)載均衡,幫助大家更好的理解和使用nginx,感興趣的朋友可以了解下2020-10-10

