How to Remove NGINX Server Header in Ubuntu 18.04

For me, it is good to remove the server info footprint in the response header to minimize security threats to your server. So how do you remove NGINX server header in Ubuntu 18.04?

Before going into the tutorial, most of the server that I know e.g. Apache, IIS, LiteSpeed, Tengine will return the server info in response header by default. So I’m sure there are also resources on how to remove server header on these servers.

You can verify a response header by running “curl -I <domain-name>“. Sample response header for ApacheNginxIIS, and LiteSpeed as follows:

curl -I apache.org
HTTP/1.1 200 OK
Date: Wed, 25 Dec 2019 10:18:21 GMT
Server: Apache/2.4.18 (Ubuntu)
Last-Modified: Wed, 25 Dec 2019 10:10:21 GMT
ETag: "14cfe-59a8477e48ef8"
Accept-Ranges: bytes
Content-Length: 85246
Vary: Accept-Encoding
Cache-Control: max-age=3600
Expires: Wed, 25 Dec 2019 11:18:21 GMT
Content-Type: text/html
curl -I nginx.com
HTTP/1.1 301 Moved Permanently
Server: nginx/1.17.3
Date: Wed, 25 Dec 2019 10:04:31 GMT
Content-Type: text/html
Content-Length: 169
Connection: keep-alive
Keep-Alive: timeout=15
Location: https://www.nginx.com/
curl -I litespeedtech.com
 HTTP/1.1 301 Moved Permanently
 Location: https://www.litespeedtech.com/
 X-FRAME-OPTIONS: SAMEORIGIN
 Date: Wed, 25 Dec 2019 10:08:24 GMT
 Server: LiteSpeed
 Connection: Keep-Alive
curl -I iis.net
 HTTP/1.1 301 Moved Permanently
 Content-Length: 0
 Content-Type: text/html; charset=UTF-8
 Location: https://iis.net/
 Server: Microsoft-IIS/10.0
 Date: Wed, 25 Dec 2019 10:12:21 GMT