Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change(Hide) the Nginx Server Signature?

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,

1.) Change the Nginx server name in source file(src/http/ngx_http_header_filter_module.c) to " My-Server". After that, compiled the nginx. But its not working when I load the url. Strange here is I can see my updated Signature when I use curl command. But this same is not updated in browser.

2.) So I tried 3rd party module(headers-more-nginx-module). This too not working. Getting updated name via Curl. But not in Browser.

like image 415
KMG Avatar asked Jul 06 '14 10:07

KMG


People also ask

What is Server_tokens in nginx?

The “server_tokens” directive is responsible for displaying the Nginx version number and Operating system on error pages and in the “Server” HTTP response header field as shown in the following screenshot. Nginx Version Number. To disable this, you need to turn off the server_tokens directive in /etc/nginx/nginx.

How do I disable server tokens?

Open up a terminal window and issue the command sudo nano /etc/apache2/conf-enabled/security. conf. Within that file, search for SeverTokens and set it to Prod, then search for ServerSignature and set it to Off (Figure A).

How do I stop nginx gracefully?

After that, all new processes can be shut down gracefully, by sending the QUIT signal to the new master process. Send the TERM signal to the new master process. It will then send a message to its worker processes requesting them to exit immediately, and they will all exit almost immediately.


2 Answers

If you are working in ubuntu then

  1. First install nginx-extras

    sudo apt-get install nginx-extras 
  2. Go to /etc/nginx/nginx.conf and under http add:

    http {     more_set_headers "Server: Your_New_Server_Name";     server_tokens off;  } 
  3. Restart nginx

    sudo service nginx restart 
like image 194
prakash09 Avatar answered Oct 04 '22 17:10

prakash09


Go to nginx conf and switch off server_tokens.

/etc/nginx/nginx.conf  server_tokens off; 
like image 39
naren Avatar answered Oct 04 '22 18:10

naren