skip to Main Content

ASAIK, we need to install 3rd party modules (e.g more_clear_headers) and add configure in nginx.conf to remove the server header completely.

load_module modules/ngx_http_headers_more_filter_module.so;

http {
    ...
    more_clear_headers Server;
    ...
}

However, in AMI, how to do that?

There is no package by using this command:
$ yum install more_clear_headers

2

Answers


  1. There are only commercial solutions available to install from packages. You can either use NGINX Plus (expensive), or a cheaper GetPageSpeed repository that supports Amazon Linux 2.

    Follow through the article to set up the module from GetPageSpeed repo:

    sudo yum -y install https://extras.getpagespeed.com/release-latest.rpm
    sudo yum -y install nginx-module-headers-more
    

    Now you can adjust your nginx.conf like this:

    load_module modules/ngx_http_headers_more_filter_module.so;
    
    http {
        ...
        more_clear_headers Server;
        ...
    }
    
    Login or Signup to reply.
  2. Remove at least the version number with

    server_tokens off;
    

    The Server response header will be

    Server: nginx
    

    http://nginx.org/en/docs/http/ngx_http_core_module.html#server_tokens

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search