Get the App
SLTechnology News&Howtos  ›  Servers  › 

Hide Nginx version number

Shulou Source: shulou.com Published: 2022-06-03 06:32:06 09月16日 Update

After setting up the nginx, we will generally hide the version number of the nginx to prevent others from knowing your version number and take advantage of the vulnerability of this version to gongji your system. This will make your nginx system more secure.

Nginx displays the version number by default, such as:

D:\ curl-7.66.0-win32-mingw\ bin > curl- I a.jinxing.com

HTTP/1.1 200 OK

Server: nginx/1.6.3

Date: Wed, 23 Oct 2019 02:30:24 GMT

Content-Type: text/html

Content-Length: 22

Last-Modified: Wed, 18 Sep 2019 06:56:09 GMT

Connection: keep-alive

ETag: "5d81d509-16"

Accept-Ranges: bytes

Hidden version number method:

1. Edit the nginx configuration file

Add server_tokens off to http {-}

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:

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.

Let's test it.

D:\ curl-7.66.0-win32-mingw\ bin > curl- I a.jinxing.com

HTTP/1.1 200 OK

Server: nginx

Date: Wed, 23 Oct 2019 02:41:09 GMT

Content-Type: text/html

Content-Length: 22

Last-Modified: Wed, 18 Sep 2019 06:56:09 GMT

Connection: keep-alive

ETag: "5d81d509-16"

Accept-Ranges: bytes

Tags: Version file configuration file name system security that is situation method loophole page built Riga external test Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Information vpn MySQL macOS