Halo, kalau kamu merasa tulisan saya ngebantu, kamu bisa ucapkan terima kasih lewat saweria .

If you feel this website help you, you can donate at saweria .



What I Used in This Tutorial

  1. Ubuntu Server 22.04 LTS

  2. Nginx v1.22.1 . I use ppa ondrej , it will make it easier to install other module in nginx, just using apt install nginx-extras you will get all usefull modules.


Remove or Modify Some Header in Nginx

server: nginx, Header Info We Want To Remove

server: nginx, Header Info We Want To Remove

It Will Become Like This, No server: nginx

It Will Become Like This, No server: nginx

  1. Install nginx-extras, use apt install nginx-extras
Error When nginx-extras Not Installed

Error When nginx-extras Not Installed

  1. Then go to /etc/nginx/nginx.conf, add this line at

    http {
    
        .
        .
        .
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        #you just need add this
        #this mean you will hide nginx version
        server_tokens off;
        more_clear_headers Server;
        #just two line
        .
        .
        .
    
    
    }
    
  2. Reload your nginx service systemctl reload nginx.service


Additional

Change Server Header Info

  1. You can change your server header info, go to /etc/nginx/nginx.conf. then add
   http {

       .
       .
       .
       tcp_nopush on;
       tcp_nodelay on;
       keepalive_timeout 65;
       types_hash_max_size 2048;
       #you just need add this
       server_tokens off;
       #change server info as Apache webserver
       more_set_headers 'server: Apache'
       #just two line
       .
       .
       .


   }
Change server: Header

Change server: Header


Remove Multiple Header Info

  1. Of course you can hide multiple header info

    http {
    
        .
        .
        .
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        #you just need add this
        server_tokens off;
        more_clear_headers 
        server
        location
        content-length;
        #just two line
        .
        .
        .
    
    
    }
    

    Notes, be carefull when you do this, it can break your app config