nginx隐藏版本信息
来源:互联网 发布:c语言是否窗口 编辑:程序博客网 时间:2024/06/05 04:11
1.源码编译安装一份nginx
tar xzf nginx-1.11.9.tar.gz
cd nginx-1.11.9
./configure --prefix=/usr/local/nginx
make && make install
2.启动nginx
/usr/local/nginx/sbin/nginx
3.查看nginx的版本信息
curl -I 192.168.146.134 #ip改为你自己的
如果nginx安装正确,并正常启动会看到下面的信息:
HTTP/1.1 200 OK
Server: nginx/1.11.9
Date: Sun, 05 Feb 2017 07:51:01 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Sun, 05 Feb 2017 07:48:23 GMT
Connection: keep-alive
ETag: "5896d8c7-264"
Accept-Ranges: bytes
斜体字部分标明了你所用的WEB服务器的名称和版本信息,在生产环境中暴露这些信息是不安全的。通过两种方式对上述信息进行隐藏:
一是在配置文件中加入server_tokens off;参数禁止版本信息泄漏:
再次查看web server版本信息
HTTP/1.1 200 OK
Server: nginx
Date: Sun, 05 Feb 2017 08:05:33 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Sun, 05 Feb 2017 07:48:23 GMT
Connection: keep-alive
ETag: "5896d8c7-264"
Accept-Ranges: bytes
这种情况下只能隐藏版本,不能隐藏文件名。
第二种办法是在编译的时候把源文件里的版本信息更改一下,编译完后显示的是你修改的内容。
修改源码包里的三个文件:
1.src/core下的nginx.h文件
#define nginx_version 100011
#define NGINX_VERSION "7.89"
#define NGINX_VER "GWS/" NGINX_VERSION
2.src/http下的ngx_http_header_filter_module.c文件
static char ngx_http_server_string[] = "Server: GWS" CRLF;
3.src/http下的ngx_http_special_response.c文件
static u_char ngx_http_error_tail[] =
"<hr><center>GWS</center>" CRLF
重新编译nginx:
make clean
./configure --prefix=/usr/local/nginx
make && make install
重新启动nginx后再次查看一下
HTTP/1.1 200 OK
Server: GWS
Date: Sun, 05 Feb 2017 08:33:58 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Sun, 05 Feb 2017 08:24:02 GMT
Connection: keep-alive
ETag: "5896e122-264"
Accept-Ranges: bytes
server的输出内容变成了我自己改的名称。
tar xzf nginx-1.11.9.tar.gz
cd nginx-1.11.9
./configure --prefix=/usr/local/nginx
make && make install
2.启动nginx
/usr/local/nginx/sbin/nginx
3.查看nginx的版本信息
curl -I 192.168.146.134 #ip改为你自己的
如果nginx安装正确,并正常启动会看到下面的信息:
HTTP/1.1 200 OK
Server: nginx/1.11.9
Date: Sun, 05 Feb 2017 07:51:01 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Sun, 05 Feb 2017 07:48:23 GMT
Connection: keep-alive
ETag: "5896d8c7-264"
Accept-Ranges: bytes
斜体字部分标明了你所用的WEB服务器的名称和版本信息,在生产环境中暴露这些信息是不安全的。通过两种方式对上述信息进行隐藏:
一是在配置文件中加入server_tokens off;参数禁止版本信息泄漏:
再次查看web server版本信息
HTTP/1.1 200 OK
Server: nginx
Date: Sun, 05 Feb 2017 08:05:33 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Sun, 05 Feb 2017 07:48:23 GMT
Connection: keep-alive
ETag: "5896d8c7-264"
Accept-Ranges: bytes
这种情况下只能隐藏版本,不能隐藏文件名。
第二种办法是在编译的时候把源文件里的版本信息更改一下,编译完后显示的是你修改的内容。
修改源码包里的三个文件:
1.src/core下的nginx.h文件
#define nginx_version 100011
#define NGINX_VERSION "7.89"
#define NGINX_VER "GWS/" NGINX_VERSION
2.src/http下的ngx_http_header_filter_module.c文件
static char ngx_http_server_string[] = "Server: GWS" CRLF;
3.src/http下的ngx_http_special_response.c文件
static u_char ngx_http_error_tail[] =
"<hr><center>GWS</center>" CRLF
重新编译nginx:
make clean
./configure --prefix=/usr/local/nginx
make && make install
重新启动nginx后再次查看一下
HTTP/1.1 200 OK
Server: GWS
Date: Sun, 05 Feb 2017 08:33:58 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Sun, 05 Feb 2017 08:24:02 GMT
Connection: keep-alive
ETag: "5896e122-264"
Accept-Ranges: bytes
server的输出内容变成了我自己改的名称。
0 0
- nginx隐藏版本信息
- 隐藏nginx 版本号信息
- Nginx隐藏响应头信息的Server信息和版本信息
- 隐藏Tomcat版本信息
- 隐藏服务器版本信息
- Nginx隐藏软件版本号信息
- 隐藏Nginx服务版本号信息
- 隐藏响应头中Apache、nginx或PHP的版本信息
- Apache、PHP 隐藏版本信息
- 隐藏Linux版本信息显示
- [2017-11-08]隐藏Nginx版本
- apache和apache2如何隐藏版本信息
- 如何隐藏bind的版本信息
- 隐藏apache和php的版本信息
- 隐藏服务器信息 与 php版本
- Apache、PHP 服务器隐藏版本信息
- Cesium 隐藏三维地球版本信息
- 修改内核文件屏蔽nginx版本信息
- HTTPS的工作原理
- OpenGL核心技术之模版测试
- Android 热更新 Bugly(Tinker)接入
- springmvc工程文件上传下载
- poj 3096 Surprising Strings
- nginx隐藏版本信息
- 文件格式转换小工具
- C++ STL标准入门汇总
- System.Web.HttpContext.Current.Cache与System.Web.HttpRuntime.Cache指向同一个引用
- 新签名文件配置方式
- 特征的转换_05-标签索引的转换与特征的组合
- jquery 设置浏览器屏蔽键盘回退功能
- iOS子线程更新UI的两种方法
- 对话框中添加状态栏