How to change(Hide) the Nginx Server Signature?

centos, linux, nginx

Solution

If you are working in ubuntu then

First install `nginx-extras`

sudo apt-get install nginx-extras

Go to `/etc/nginx/nginx.conf` and under `http` add:

http {
    more_set_headers "Server: Your_New_Server_Name";
    server_tokens off; 
}

Restart nginx

sudo service nginx restart

Problem

I can hide NGINX version by using `server_tokens` option set to `off`. But not able to change the NGINX Server signature. Steps I did: - Change the NGINX server name in source file src/http/ngx_http_header_filter_module.c to ` My-Server`, then compiled NGINX. But it is not working when I call the server. Strange here is I can see my updated Signature when I use `curl` command. But this is not updated in the browser. - I tried using a 3rd party module headers-more-nginx-module. This doesn't work either. I am getting the updated name via cURL but not in browser.

Original source