How to hide and forge version number in Nginx

How to hide and forge version number in Nginx

1. Use curl command to access by default:

# curl -I http://172.17.0.5

2. Modify the nginx.conf configuration file and add the following code in the http configuration section:

# vim /usr/local/nginx/conf/nginx.conf
server_tokens off; 

3. Modify the fastcgi.conf configuration file and comment the following code:

# vim /usr/local/nginx/conf/fastcgi.conf
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

4. Reload Nginx:

# nginx -s reload

5. Use curl command to access:

# curl -I http://172.17.0.5

6. Forge the name and version number of Nginx:

# vim /usr/src/nginx-1.16.1/src/core/nginx.h, modify the following code #define NGINX_VERSION "1.16.1" --> #define NGINX_VERSION "2.3.2"
#define NGINX_VER "nginx/" NGINX_VERSION --> #define NGINX_VER "Tengine/" NGINX_VERSION
# cd /usr/src/nginx-1.16.1
# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-threads --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-mail_ssl_module --with-stream --with-stream_ssl_module --with-stream_realip_module --with-stream_geoip_module --with-stream_ssl_preread_module --with-compat --with-pcre
# make && make install
# cd /usr/local/nginx/conf
# vim nginx.conf, delete the previously added code: server_tonkens off;
# nginx -s stop
# nginx

7. Use curl command to access:

# curl -I http://172.17.0.5

Summarize

The above is the operation method of hiding and forging Nginx version number 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!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

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

<<:  Detailed explanation of the basic usage of the auxiliary function mapGetters in vuex

>>:  Solve MySQL deadlock routine by updating different indexes

Recommend

How to use MySQL limit and solve the problem of large paging

Preface In daily development, when we use MySQL t...

Detailed explanation of Linux one-line command to process batch files

Preface The best method may not be the one you ca...

Shell script nginx automation script

This script can satisfy the operations of startin...

Example of implementing colored progress bar animation using CSS3

Brief Tutorial This is a CSS3 color progress bar ...

A brief discussion on React Component life cycle functions

What are the lifecycle functions of React compone...

How to bypass unknown field names in MySQL

Preface This article introduces the fifth questio...

Summary and practice of javascript prototype chain diagram

Table of contents Prototype chain We can implemen...

8 JS reduce usage examples and reduce operation methods

reduce method is an array iteration method. Unlik...

A small collection of html Meta tags

<Head>……</head> indicates the file he...

Detailed steps for installing ros2 in docker

Table of contents Main topic 1. Install Docker on...

Vue3.0 implements the magnifying glass effect case study

The effect to be achieved is: fixed zoom in twice...

How to set directory whitelist and IP whitelist in nginx

1. Set a directory whitelist: Do not set restrict...

Application examples of WeChat applet virtual list

Table of contents Preface What is a virtual list?...

Two practical ways to enable proxy in React

Two ways to enable proxy React does not have enca...