How to solve the problem of nginx hidden version number and WEB server information

WBOY
Release: 2023-05-21 09:13:05
forward
1636 people have browsed it

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 solve the problem of nginx hidden version number and WEB server information

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
Copy after login

2 Unzip

tar -xf nginx-1.14.1.tar.gzcd nginx-1.14.1
Copy after login

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


How to solve the problem of nginx hidden version number and WEB 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

How to solve the problem of nginx hidden version number and WEB server information

4 Compile configuration

./configure --prefix=/usr/local/nginx
Copy after login

5 Compile and install

make && make install
Copy after login

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;
.....
Copy after login

How to solve the problem of nginx hidden version number and WEB server information

7 Start nginx

/usr/local/nginx/sbin/nginx
Copy after login

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
  ......
Copy after login

Browser access test

 How to solve the problem of nginx hidden version number and WEB server information

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template