Hide Your Nginx's Header On Ubuntu

Hide Your Nginx

Did you know you can hide your web server header? So what purpose of this approach?

I believe this is the best for the security practice.

So here we go. We need to get the sources/dependecies first.

Upgrade nginx to the latest stable

$ sudo apt install software-properties-common nginx=stable

Add nginx repository

$ sudo add-apt-repository -y ppa:nginx/$nginx

Update the package lists

$ sudo apt update
$ sudo apt dist-upgrade

Check nginx version

$ nginx -v

Install nginx-extras

$ sudo apt install nginx-extras

Edit Nginx configuration file

$ sudo vim /etc/nginx/nginx.conf

Add modules in the first line and more_set_headers in http block

load_module modules/ngx_http_headers_more_filter_module.so;

http {
	more_set_headers "Server: Your Server";
}

Test your nginx config and restart it

$ sudo nginx -t
$ sudo service nginx restart

That’s it!