Tutorial

How to hide NGINX server version from header response.

When you install the NGINX server for your website, 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

This tutorial article will discuss how we can hide the server version from nginx and customize Bitnami nginx.

Hide the NGINX server version from the header response.

We’ll guide you on hiding the NGINX server version from the header response of your website. You can implement this method on standard nginx or Bitnami stack nginx applications.

nginx-with-server-version
nginx with the server version

Configure nginx.conf file

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

Open the nginx server configuration file.

To open the configuration, 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 the 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 the status of nginx settings and execute 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 the system response by executing.

 curl -I https://example.com/

Using the above method, you can remove the nginx server version from the website’s header so that you keep your self-hosted project safe and sound.

Hide the NGINX server version from Bitnami

Bitnami uses a customized nginx server to make its a user easy to understand its files and locations. And also provide a very secure PHPMyAdmin page for its users to protect the website from hackers.

You can hide the nginx server version by editing nginx.conf file of WordPress Bitnami nginx. You’ve to locate the file and add the code 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 the 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 to update the settings. Finally, you can test setting files by executing the following command.

nginx -t

If your system responds with ok status, you can reload the new configuration in the system or restart it.

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

After restarting the system, you can check the header response.

Finally NGINX version hidden
nginx header response with the 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 Sihmar

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button