默认的版本信息一般会暴露服务器所使用的开源软件、版本、可能被恶意引用导致不必要的麻烦,因此有时候可以做一些调整,禁止或者改变默认头信息。
修改前修改:
0 1 2 3 4 5 6 7 8 9 |
[go@centos7 ~]$ curl --head home.baidu.com HTTP/1.1 200 OK Date: Sun, 20 Mar 2016 04:55:32 GMT Server: Apache/2.2.31 (Unix) Last-Modified: Sat, 19 Mar 2016 11:30:18 GMT ETag: "ea071e-259b-52e6530272680" Accept-Ranges: bytes Content-Length: 9627 Connection: close Content-Type: text/html |
修改后:
0 1 2 3 4 5 6 7 8 9 |
[go@centos ~]$ curl --head home.baidu.com HTTP/1.1 200 OK Server: Byrd Date: Sun, 20 Mar 2016 04:56:39 GMT Content-Type: text/html Content-Length: 69 Last-Modified: Sun, 21 Feb 2016 13:58:39 GMT Connection: keep-alive ETag: "56c9c28f-45" Accept-Ranges: bytes |
修改代码:
0 1 2 3 |
[root@centos nginx-1.6.3]# grep Byrd . -r ./src/http/ngx_http_special_response.c:"<hr><center>Byrd</center>" CRLF ./src/http/ngx_http_header_filter_module.c:static char ngx_http_server_string[] = "Server: Byrd" CRLF; ./src/core/nginx.h:#define NGINX_VER "Byrd/" NGINX_VERSION |
参考:https://www.ttlsa.com/nginx/nginx-custom-header-to-return-information-module-ngx_headers_more/
参考:http://www.jb51.net/article/38349.htm SourceByrd's Weblog-https://note.t4x.org/system/service-nginx-head-connection/
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!