隐藏nginx 版本等信息
2015-09-24 09:42
711 查看
隐藏nginx 版本等信息
[root@LNMP ~]# curl -I 127.0.0.1
HTTP/1.1 200 OK
Server: nginx/1.6.2
Date: Thu, 24 Sep 2015 00:59:17 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 22 Sep 2015 07:55:24 GMT
Connection: keep-alive
ETag: "5601096c-264"
Accept-Ranges: bytes
[root@LNMP ~]#
修改在http模块增加下面内容
http {
########################start
server_tokens off;
########################end
}
#######重启nginx服务
/application/nginx/sbin/nginx -s reload
[root@LNMP conf]# ../sbin/nginx -s reload
[root@LNMP conf]# curl -I 127.0.0.1
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 24 Sep 2015 01:01:05 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 22 Sep 2015 07:55:24 GMT
Connection: keep-alive
ETag: "5601096c-264"
Accept-Ranges: bytes
[root@LNMP conf]#
[root@LNMP conf]# curl -I -s 10.0.0.4 | grep Server
Server: nginx
##########################
隐藏软件名称
cd /home/lvnian/tools/nginx-1.6.2
curl -I 127.0.0.1
curl -I -s 10.0.0.4 | grep Server
cd /home/lvnian/tools/nginx-1.6.2
grep 1.6.2 src/core/nginx.h
sed -i 's#1.6.2#2.2.22#g' src/core/nginx.h
grep 2.2.22 src/core/nginx.h
grep nginx/ src/core/nginx.h
sed -i 's#nginx/#lvnian/#g' src/core/nginx.h
grep lvnian/ src/core/nginx.h
###########################具体过程
[root@LNMP conf]# curl -I -s 10.0.0.4 | grep Server
Server: nginx
[root@LNMP conf]# cd /home/lvnian/tools/nginx-1.6.2
[root@LNMP nginx-1.6.2]# grep 1.6.2 src/core/nginx.h
#define NGINX_VERSION "1.6.2"
[root@LNMP nginx-1.6.2]# sed -i 's#1.6.2#2.2.22#g' src/core/nginx.h
[root@LNMP nginx-1.6.2]# grep 2.2.22 src/core/nginx.h
#define NGINX_VERSION "2.2.22"
[root@LNMP nginx-1.6.2]# grep nginx/ src/core/nginx.h
#define NGINX_VER "nginx/" NGINX_VERSION
[root@LNMP nginx-1.6.2]# sed -i 's#nginx/#lvnian/#g' src/core/nginx.h
[root@LNMP nginx-1.6.2]# grep lvnian/ src/core/nginx.h
#define NGINX_VER "lvnian/" NGINX_VERSION
[root@LNMP nginx-1.6.2]#
########################修改ngx_http_header_filter_module.c
cd /home/lvnian/tools/nginx-1.6.2/src/http/
vim ngx_http_header_filter_module.c ##修改49/50行成下面内容
49 static char ngx_http_server_string[] = "Server: lvnian" CRLF;
50 static char ngx_http_server_full_string[] = "Server:lvnian" NGINX_VER CRLF;
##########################
或者用sed 修改
grep '"Server:' ngx_http_header_filter_module.c
cp ngx_http_header_filter_module.c ngx_http_header_filter_module.c.ori
sed -i 's/"Server:/"Server:lvnian/g' ngx_http_header_filter_module.c
grep '"Server:' ngx_http_header_filter_module.c
sed -i 's/"Server:lvnian nginx/"Server:lvnian/g' ngx_http_header_filter_module.c
grep '"Server:' ngx_http_header_filter_module.c
####################sed 修改过程
[root@LNMP http]# grep '"Server:' ngx_http_header_filter_module.c
static char ngx_http_server_string[] = "Server: nginx" CRLF;
static char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF;
[root@LNMP http]# cp ngx_http_header_filter_module.c ngx_http_header_filter_module.c.ori
[root@LNMP http]# sed -i 's/"Server:/"Server:lvnian/g' ngx_http_header_filter_module.c
[root@LNMP http]# grep '"Server:' ngx_http_header_filter_module.c
static char ngx_http_server_string[] = "Server:lvnian nginx" CRLF;
static char ngx_http_server_full_string[] = "Server:lvnian " NGINX_VER CRLF;
[root@LNMP http]# sed -i 's/"Server:lvnian nginx/"Server:lvnian/g' ngx_http_header_filter_module.c
[root@LNMP http]# grep '"Server:' ngx_http_header_filter_module.c static char ngx_http_server_string[] = "Server:lvnian" CRLF;
static char ngx_http_server_full_string[] = "Server:lvnian " NGINX_VER CRLF;
########################修改 vim ngx_http_special_response.c
vim ngx_http_special_response.c ##修改成下面内容
29:"<hr><center>lvnian</center>" CRLF
####或者sed 修改,命令如下:
grep 'nginx' ngx_http_special_response.c
sed -i 's/>nginx</>lvnian</' ngx_http_special_response.c
grep 'nginx' ngx_http_special_response.c
grep 'lvnian' ngx_http_special_response.c
#####sed 修改过程
[root@LNMP http]# grep 'nginx' ngx_http_special_response.c
#include <nginx.h>
"<hr><center>nginx</center>" CRLF
[root@LNMP http]# sed -i 's/>nginx</>lvnian</' ngx_http_special_response.c
[root@LNMP http]# grep 'nginx' ngx_http_special_response.c
#include <nginx.h>
[root@LNMP http]# grep 'lvnian' ngx_http_special_response.c
"<hr><center>lvnian</center>" CRLF
#############################重新编译
cd /home/lvnian/tools/nginx-1.6.2
cp /application/nginx/conf /tmp/ -rp
rm -rf /application/ngin*
./configure --user=nginx --group=nginx --prefix=/application/nginx-1.6.2 --with-http_stub_status_module --with-http_ssl_module
make && make install
pkill nginx
curl -I 127.0.0.1
/application/nginx-1.6.2/sbin/nginx
#################
[root@LNMP nginx-1.6.2]# curl -I 127.0.0.1
HTTP/1.1 200 OK
Server:lvnian lvnian/2.2.22
Date: Thu, 24 Sep 2015 01:38:03 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Thu, 24 Sep 2015 01:36:48 GMT
Connection: keep-alive
ETag: "560353b0-264"
Accept-Ranges: bytes
打开该站点不存在的一个网页,显示如下
[root@LNMP ~]# curl -I 127.0.0.1
HTTP/1.1 200 OK
Server: nginx/1.6.2
Date: Thu, 24 Sep 2015 00:59:17 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 22 Sep 2015 07:55:24 GMT
Connection: keep-alive
ETag: "5601096c-264"
Accept-Ranges: bytes
[root@LNMP ~]#
修改在http模块增加下面内容
http {
########################start
server_tokens off;
########################end
}
#######重启nginx服务
/application/nginx/sbin/nginx -s reload
[root@LNMP conf]# ../sbin/nginx -s reload
[root@LNMP conf]# curl -I 127.0.0.1
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 24 Sep 2015 01:01:05 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 22 Sep 2015 07:55:24 GMT
Connection: keep-alive
ETag: "5601096c-264"
Accept-Ranges: bytes
[root@LNMP conf]#
[root@LNMP conf]# curl -I -s 10.0.0.4 | grep Server
Server: nginx
##########################
隐藏软件名称
cd /home/lvnian/tools/nginx-1.6.2
curl -I 127.0.0.1
curl -I -s 10.0.0.4 | grep Server
cd /home/lvnian/tools/nginx-1.6.2
grep 1.6.2 src/core/nginx.h
sed -i 's#1.6.2#2.2.22#g' src/core/nginx.h
grep 2.2.22 src/core/nginx.h
grep nginx/ src/core/nginx.h
sed -i 's#nginx/#lvnian/#g' src/core/nginx.h
grep lvnian/ src/core/nginx.h
###########################具体过程
[root@LNMP conf]# curl -I -s 10.0.0.4 | grep Server
Server: nginx
[root@LNMP conf]# cd /home/lvnian/tools/nginx-1.6.2
[root@LNMP nginx-1.6.2]# grep 1.6.2 src/core/nginx.h
#define NGINX_VERSION "1.6.2"
[root@LNMP nginx-1.6.2]# sed -i 's#1.6.2#2.2.22#g' src/core/nginx.h
[root@LNMP nginx-1.6.2]# grep 2.2.22 src/core/nginx.h
#define NGINX_VERSION "2.2.22"
[root@LNMP nginx-1.6.2]# grep nginx/ src/core/nginx.h
#define NGINX_VER "nginx/" NGINX_VERSION
[root@LNMP nginx-1.6.2]# sed -i 's#nginx/#lvnian/#g' src/core/nginx.h
[root@LNMP nginx-1.6.2]# grep lvnian/ src/core/nginx.h
#define NGINX_VER "lvnian/" NGINX_VERSION
[root@LNMP nginx-1.6.2]#
########################修改ngx_http_header_filter_module.c
cd /home/lvnian/tools/nginx-1.6.2/src/http/
vim ngx_http_header_filter_module.c ##修改49/50行成下面内容
49 static char ngx_http_server_string[] = "Server: lvnian" CRLF;
50 static char ngx_http_server_full_string[] = "Server:lvnian" NGINX_VER CRLF;
##########################
或者用sed 修改
grep '"Server:' ngx_http_header_filter_module.c
cp ngx_http_header_filter_module.c ngx_http_header_filter_module.c.ori
sed -i 's/"Server:/"Server:lvnian/g' ngx_http_header_filter_module.c
grep '"Server:' ngx_http_header_filter_module.c
sed -i 's/"Server:lvnian nginx/"Server:lvnian/g' ngx_http_header_filter_module.c
grep '"Server:' ngx_http_header_filter_module.c
####################sed 修改过程
[root@LNMP http]# grep '"Server:' ngx_http_header_filter_module.c
static char ngx_http_server_string[] = "Server: nginx" CRLF;
static char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF;
[root@LNMP http]# cp ngx_http_header_filter_module.c ngx_http_header_filter_module.c.ori
[root@LNMP http]# sed -i 's/"Server:/"Server:lvnian/g' ngx_http_header_filter_module.c
[root@LNMP http]# grep '"Server:' ngx_http_header_filter_module.c
static char ngx_http_server_string[] = "Server:lvnian nginx" CRLF;
static char ngx_http_server_full_string[] = "Server:lvnian " NGINX_VER CRLF;
[root@LNMP http]# sed -i 's/"Server:lvnian nginx/"Server:lvnian/g' ngx_http_header_filter_module.c
[root@LNMP http]# grep '"Server:' ngx_http_header_filter_module.c static char ngx_http_server_string[] = "Server:lvnian" CRLF;
static char ngx_http_server_full_string[] = "Server:lvnian " NGINX_VER CRLF;
########################修改 vim ngx_http_special_response.c
vim ngx_http_special_response.c ##修改成下面内容
29:"<hr><center>lvnian</center>" CRLF
####或者sed 修改,命令如下:
grep 'nginx' ngx_http_special_response.c
sed -i 's/>nginx</>lvnian</' ngx_http_special_response.c
grep 'nginx' ngx_http_special_response.c
grep 'lvnian' ngx_http_special_response.c
#####sed 修改过程
[root@LNMP http]# grep 'nginx' ngx_http_special_response.c
#include <nginx.h>
"<hr><center>nginx</center>" CRLF
[root@LNMP http]# sed -i 's/>nginx</>lvnian</' ngx_http_special_response.c
[root@LNMP http]# grep 'nginx' ngx_http_special_response.c
#include <nginx.h>
[root@LNMP http]# grep 'lvnian' ngx_http_special_response.c
"<hr><center>lvnian</center>" CRLF
#############################重新编译
cd /home/lvnian/tools/nginx-1.6.2
cp /application/nginx/conf /tmp/ -rp
rm -rf /application/ngin*
./configure --user=nginx --group=nginx --prefix=/application/nginx-1.6.2 --with-http_stub_status_module --with-http_ssl_module
make && make install
pkill nginx
curl -I 127.0.0.1
/application/nginx-1.6.2/sbin/nginx
#################
[root@LNMP nginx-1.6.2]# curl -I 127.0.0.1
HTTP/1.1 200 OK
Server:lvnian lvnian/2.2.22
Date: Thu, 24 Sep 2015 01:38:03 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Thu, 24 Sep 2015 01:36:48 GMT
Connection: keep-alive
ETag: "560353b0-264"
Accept-Ranges: bytes
打开该站点不存在的一个网页,显示如下
相关文章推荐
- "Nginx服务器在使用HTML5
- nginx配置语法
- nginx+fastcgi+c/cpp
- 隐藏nginx版本号,以加强服务安全
- 用GoAccess来分析Nginx日志
- 关于部署StartCom免费证书,FireFox不信任的问题
- Nginx: error while loading shared libraries: libpcre.so.1
- 通过修改配置真正解决php文件上传大小限制问题(nginx+php)
- sentos nginx安装
- nginx 并发数问题思考:worker_connections,worker_processes与 max clients
- 强大的负载均衡+静态文件WEB服务器nginx实战
- nginx中配置pathinfo模式示例
- rails 部署 nginx + passenger
- Nginx和Apache共存环境下apache获得真实IP
- nginx 502排错
- nginx + passenger 出现 Cannot stat .../config.ru': Permission denied 的错误的解决办法
- nginx解析php请求为404
- 最完美解决Nginx部署ThinkPHP项目的办法
- LNMP实现(CentOS7+Nginx-1.9.4+PHP-5.6+MySQL-5.6.26)
- #研发解决方案#基于Apriori算法的Nginx+Lua+ELK异常流量拦截方案