Solution to nginx hiding version number and WEB server information

Solution to nginx hiding 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 results first.

How to implement it specifically? It is actually very simple. Please read on.

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 your custom server information after Server


(2) vim src/http/ngx_http_special_response.c #Modify line 36
"<hr><center>Please guess it!</center>" 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 Testing

[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

illustrate:

(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 want to customize the string while upgrading nginx, there is no problem. You can modify the C file first --> ./configure --> make

Summarize

The above is the solution to hide the version number and WEB server information of nginx introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • How to hide and forge version number in Nginx
  • How to hide the version number in Nginx
  • How to hide the version number and web page cache time in Nginx
  • Multiple ways to configure nginx to hide the version number

<<:  Solve the MySQL 5.7.9 version sql_mode=only_full_group_by problem

>>:  Implementing Binary Search Tree in JavaScript

Recommend

Comparison of two implementation methods of Vue drop-down list

Two implementations of Vue drop-down list The fir...

Install three or more tomcats under Linux system (detailed steps)

If you want to install multiple tomcats, you must...

Solve the problem of case sensitivity of Linux+Apache server URL

I encountered a problem today. When entering the ...

Analysis of several situations where MySQL index fails

1. Best left prefix principle - If multiple colum...

Detailed explanation of js's event loop event queue in the browser

Table of contents Preface Understanding a stack a...

The presentation and opening method of hyperlink a

<br />Related articles: How to prompt and op...

A brief introduction to JavaScript arrays

Table of contents Introduction to Arrays Array li...

How to manage cached pages in Vue

Table of contents Problem 1: Destruction 1. How t...

Use vertical-align to align input and img

Putting input and img on the same line, the img ta...

Mysql splits string into array through stored procedure

To split a string into an array, you need to use ...

Simple implementation of mini-vue rendering

Table of contents Preface Target first step: Step...

Using HTML+CSS to track mouse movement

As users become more privacy-conscious and take m...

VMWare virtual machine 15.X LAN network configuration tutorial diagram

Recently, I have been working on several virtual ...

Echarts Bar horizontal bar chart example code

Table of contents Horizontal bar chart Dynamicall...