nginx can not only hide version information, but also support custom web server information
Let’s take a look at the final hidden result
How to implement it specifically , it is actually very simple, please read below
1 Download the latest stable version from the official website
wget http://nginx.org/download/nginx-1.14.1.tar.gz
2 Unzip
tar -xf nginx-1.14.1.tar.gzcd nginx-1.14.1
3 Modify the 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!" crlf; #Write you after server Customized server information
(2) vim src/http/ngx_http_special_response.c #Modify line 36
"< hr>please guess it! " crlf #Write the string just now again
4 Compile 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 200 ok server: please guess it! date: wed, 07 nov 2018 19:15:43 gmt ......
Browser access test
Instructions:
(1) If you just want to hide version number, and do not want to customize the server information, there is no need to perform step 3.
(2) If you upgrade nginx and also need to customize the string, there is no problem. You can modify the c file first - ->./configure --> just make
The above is the detailed content of How to solve the problem of nginx hidden version number and WEB server information. For more information, please follow other related articles on the PHP Chinese website!