Hide server nginx, apache in Respone Header

image-2-1024x682 Hide server nginx, apache in Respone Header

Solution 1 : Use the 3rd-party “Headers More” Module :

Upgrade nginx-common and nginx-extras :

sudo apt-get install nginx-common
sudo apt-get install nginx-extras

Configuration nginx.conf

nano /etc/nginx/nginx.conf
##Add this one :
load_module modules/ngx_http_headers_more_filter_module.so;
http {
    ...
       more_clear_headers Server;
    ...
}

Test Nginx

nginx -t
service nginx reload

Solution 2 : Install and Compile new module Headers-More-Nginx-Module

Download your version nginx :

wget http://nginx.org/download/nginx-1.12.2.tar.gz

Decompress your nginx.tar :

tar -xvzf nginx-1.12.2.tar.gz 

Download the source code of the dynamic module we need to compile :

git clone https://github.com/openresty/headers-more-nginx-module.git

Go to Nginx File

cd ~/nginx1.12.2

Compile and run source :

./configure --with-compat --add-dynamic-module=../headers-more-nginx-module
make modules 

In objs directory the “module.so” file will be created, copy the file to nginx modules directory :

sudo cp objs/ngx_http_headers_more_filter_module.so /usr/lib/nginx/modules

Let nginx know about the newly compiled module, add the following line in your nginx.conf file :

load_module modules/ngx_http_headers_more_filter_module.so;

And in the HTTP block of the engine.conf, add :

server_tokens off;
more_set_headers 'Server: Thanhnh';
// or 
more_set_header Server;

I am gaining experience and developing my skills in the field of information technology. My focus areas include basic network administration, troubleshooting, and supporting IT infrastructure. I am keen on learning and growing in various aspects of IT, from system setup and maintenance to exploring new technologies and methodologies.

Post Comment