Tutorial

How to hide NGINX server version from header response.

When you install the NGINX server for your website, by default it responds with its version details when we check its header response. You must hide the nginx server version from the header response, as hackers can use this information for suspicious activities.

Hide NGINX server version header
Hide NGINX server version header

In this tutorial article, we’ll understand how we can hide the server version from nginx, and from customized bitnami nginx.

Hide NGINX server version from header response.

We’ll guide you on how you can hide the NGINX server version from the header response of your website. You’re using a normal nginx server and also using a bitnami nginx application.

nginx-with-server-version
nginx with server version

Configure nginx.conf file

You have to make some changes in the configuration of the nginx server so that it hides the server information. You’ve to open the SSH terminal of your website and execute the following command.

Open nginx server configuration file.

To open configuation you’ve to execute the following command.

sudo -i
sudo /etc/nginx/nginx.conf

Now hide the server version.

For this, you’ve to locate the http block of your nginx server configuration and add server_tokens off; into the block, as displayed below.

http {
    ...

    server_tokens off;
    ...
}

Now save the changes by pressing ctrl+X, then Y and then press enter.

Now you’ve to check status of nginx settings, exectute the command.

sudo nginx -t

It will respond as the system configuration is ok. Now you can restart the nginx. Execute the following command to restart the nginx server.

sudo service nginx reload #debian/ubuntu
systemctl restart nginx #redhat/centos

After restarting the system you can check system response by executing.

 curl -I https://example.com/

Using the above method you can remove the nginx server version from the header of the website. So that you keep your self hosted project safe and sound.

Hide NGINX server version from Bitnami

Bitnami uses a customized nginx server, that tries to make a user easy to understand its files and locations. And also provide a very secure phpmyadmin page for its users, so that website can be safe.

You can hide nginx server version by editing nginx.conf file of WordPress bitnami nginx. You’ve just to locate the file and add the code in the same way as we did above.

Access nginx.conf file of the stack

NGINX server version located in /opt/bitnami/nginx/conf/nginx.conf. To edit this you’ve to access the server with full permission.

sudo -i
nano /opt/bitnami/nginx/conf/nginx.conf

Edit nginx.conf file of bitnami stack

Here you’ve to add the following lines to hide the server version of your application.

http {
    ...

    server_tokens off;
    ...
}

Now save the configuration by using ctrl+X, then Y, and then press enter. Your new settings will be saved. You can test setting files by executing the following command.

nginx -t

Now if your system responds with ok status then you can reload the new configuration in the system or just restart it

nginx -s reload
sudo /opt/bitnami/ctlscript.sh restart nginx

After restarting the system you can check header response.

nginx header response with server version.

So using the command line you can hide server version information from the header response.

I hope you liked this article, in case of any doubt feel free to contact us or comment in the comment section provided below.

Ashok Kumar

Ashok Kumar working in the Search Engine Optimization field since 2015. And worked on many successful projects since then. He shares the real-life experience of best SEO practices with his followers on seoneurons.com. You also can learn Advance level SEO for WordPress, Blogger, or any other blogging platform. Stay tuned.

Related Articles

Leave a Reply

Back to top button