Hide Nginx version number
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