server_tokensとは、エラーページと "Server "レスポンスヘッダフィールドにnginxのバージョンを表示するかどうかを設定するディレクティブ
デフォルトはonなのでnginxのバージョンが表示される。
↓デフォルト
$ curl localhost -I
HTTP/1.1 200 OK
Server: nginx/1.14.1 * これ
Date: Fri, 11 Dec 2020 14:07:20 GMT
Content-Type: text/html
Content-Length: 4057
Last-Modified: Mon, 07 Oct 2019 21:16:24 GMT
Connection: keep-alive
ETag: "5d9bab28-fd9"
Accept-Ranges: bytes
↓offにする。nginxのバージョン情報が消える。
nginx.conf
server_tokens off;
$ curl localhost -I
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 11 Dec 2020 14:10:54 GMT
Content-Type: text/html
Content-Length: 4057
Last-Modified: Mon, 07 Oct 2019 21:16:24 GMT
Connection: keep-alive
ETag: "5d9bab28-fd9"
Accept-Ranges: bytes