Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to hide the Nginx version number

Shulou Source: shulou.com Published: 2022-05-31 13:10:35 10月19日 Update

This article introduces the knowledge of "how to hide the Nginx version number". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Nginx displays the version number by default, such as:

[root@hadooptest] # curl-I www.nginx.orghttp/1.1 200 okserver: nginx/0.8.44date: tue, 13 jul 2010 14:05:11 gmtcontent-type: text/htmlcontent-length: 8284last-modified: tue, 13 jul 2010 12:00:13 gmtconnection: keep-alivekeep-alive: timeout=15accept-ranges: bytes

In this way, people will see that your server nginx version is 0.8.44. some time ago, there were some nginx version vulnerabilities, that is, some versions have vulnerabilities and some versions do not. In this way, the exposed version number can easily become information that can be used by an attacker. Therefore, from a security point of view, the hidden version number will be relatively safe!

Can the nginx version number be hidden? Actually, you can. Take a look at my steps below:

1. Enter the directory of the nginx configuration file (this directory is decided at the time of installation) and open it with vim editing

Vim nginx.conf

Add server_tokens off; to http {-} such as:

The copy code is as follows:

Http {

…… Omit

Sendfile on

Tcp_nopush on

Keepalive_timeout 60

Tcp_nodelay on

Server_tokens off

…… . Omit

}

2. Edit the php-fpm configuration file, such as fastcgi.conf or fcgi.conf (this configuration file name can also be customized and modified according to the specific file name):

Find:

Fastcgi_param server_software nginx/$nginx_version

Change to:

Fastcgi_param server_software nginx

3. Reload the nginx configuration:

# / etc/init.d/nginx reload

In this way, the nginx version number is completely hidden, and the nginx version will not be displayed even if there are 404,501 pages.

The modified content is as follows:

[root@hadooptest] # curl-I www.nginx.orghttp/1.1 200okserver: nginxdate: tue, 13 jul 2010 14:05:11 gmtcontent-type: text/htmlcontent-length: 8284last-modified: tue, 13 jul 2010 12:00:13 gmtconnection: keep-alivekeep-alive: timeout=15accept-ranges: bytes, that's all for "how to hide Nginx version numbers". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Version file configuration content security code that is file name more loophole directory knowledge practical successful learning and then information dilemma actual that is the situation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS vpn Shulou Technology Microsoft Linux