The solution of nginx Hidden version number and WEB Server Information
Nginx can not only hide version information, but also support custom web server information.
Let's take a look at the final hidden result first.
How to achieve it? in fact, it is very simple. Please read on.
1 download the latest stable version on the official website
Wget http://nginx.org/download/nginx-1.14.1.tar.gz
2 decompression
Tar-xf nginx-1.14.1.tar.gzcd nginx-1.14.1
3 modify C file
(1) vim src/http/ngx_http_header_filter_module.c # modify line 49
Static u_char ngx_http_server_string [] = "Server: Please guess it!" Write your custom server information after CRLF; # Server
(2) vim src/http/ngx_http_special_response.c # modify 36 lines
"Please guess it!" CRLF # write the string again
4 compilation configuration
. / configure-- prefix=/usr/local/nginx
5 compile and install
Make & & make install
6 modify the nginx configuration file and add server_tokens off under the http node
Vim / usr/local/nginx/conf/nginx.conf....http {server_tokens off;.
7 start nginx
/ usr/local/nginx/sbin/nginx
8 Test
[root@node1 nginx-1.14.1] # curl-I http://127.0.0.1 HTTP/1.1 200OK Server: Please guess it! Date: Wed, 07 Nov 2018 19:15:43 GMT.
Browser access test
Description:
(1) if you only want to hide the version number and do not want to customize the server information, you do not need to perform step 3.
(2) if you need to customize the string while upgrading the nginx, you can modify the C file-- >. / configure-- > make first.
Summary
The above is the solution to the nginx hidden version number and WEB server information introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave a message for me, and the editor will reply to you in time. Thank you very much for your support to the website!