Disable server_tokens
How to disable Nginx version (server_tokens) in HTTP header response
By default, Nginx web server will include a HTTP header that outputs the Nginx version.
How to disable server_tokens
Prerequisites
- Root access to the web server to update the
nginx.conf
file.
Instructions
Log into your web server via SSH.
Edit the
nginx.conf
file:vi /etc/nginx/nginx.conf
Add the
server_tokens
parameter with theoff
value in theserver { }
block directive.server { listen 127.0.0.1:80; server_name mydomain.com; server_tokens off; }
Save the file
Reload the configuration file to test it:
sudo nginx -t
Restart Nginx:
sudo systemctl restart nginx