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

Example code for evenly distributing elements using css3 flex layout

This article mainly introduces how to evenly dist...

Solve the splicing problem of deleting conditions in myBatis

I just learned mybatis today and did some simple ...

What to do if you forget the initial password when installing MySQL on Mac

Forgetting the password is a headache. What shoul...

Nginx location matching rule example

1. Grammar location [=|~|~*|^~|@] /uri/ { ... } 2...

Implementation example of Nginx+Tomcat load balancing cluster

Table of contents introduction 1. Case Overview 2...

CentOS 7 installation and configuration method graphic tutorial

This article records the detailed installation tu...

Vue integrates Tencent Map to implement API (with DEMO)

Table of contents Writing Background Project Desc...

Analysis of MySQL Aborted connection warning log

Preface: Sometimes, the session connected to MySQ...

Q&A: Differences between XML and HTML

Q: I don’t know what is the difference between xml...

Using MySQL database in docker to achieve LAN access

1. Get the mysql image docker pull mysql:5.6 Note...

Detailed explanation of using Vue.prototype in Vue

Table of contents 1. Basic Example 2. Set the sco...

Vue event's $event parameter = event value case

template <el-table :data="dataList"&...

Comprehensive analysis of MySql master-slave replication mechanism

Table of contents Master-slave replication mechan...