habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

How to Hide Version nginx

1 min read

Nginx is a popular web server that powers many websites and applications. However, by default, nginx reveals its version number in the HTTP response headers and error pages. This can be a security risk, as it exposes information that can be used by attackers to exploit vulnerabilities in your server. In this post, we will show you how to hide the version number of nginx from the public.

There are two main methods to do this: using the server_tokens directive and using a custom error page.

Method 1: Hide Version nginx with server_tokens directive

The server_tokens directive controls whether nginx displays its version number and OS name in the HTTP response headers and error pages. By default, it is set to on, which means that nginx will show both the version number and the OS name.

For example, you might see something like this in the response headers:

Server: nginx/1.18.0 (Ubuntu)

To hide the version number and the OS name, you can set the server_tokens directive to off in your nginx configuration file. For example, you can add this line to the http block in /etc/nginx/nginx.conf:

server_tokens off;

This will make nginx only display its name without any additional information. For example, you will see something like this in the response headers:

Server: nginx

For change, restart service nginx.

nginx hide version
nginx hide version

Method 2: Using a Custom Error Ppage

Another way to hide the version number of nginx is to use a custom error page for common HTTP errors, such as 404 or 500. By default, nginx will show its version number and OS name in the error pages. For example, you might see something like this when you request a non-existent page:

404 Not Found
nginx/1.18.0 (Ubuntu)

To replace the default error page with your own custom on. You can use the error_page directive in your nginx configuration file. For example, you can add this line to the server block:

error_page 404 /404.html;

This will make nginx serve the file /404.html instead of the default error page when a 404 error occurs. You can create your own custom error page with any content you want, such as a friendly message or a link to your homepage. You can also use variables such as $status or $request_uri to display dynamic information.

See also  ISPConfig Ubuntu 18.04 Nginx MySQL

Next, restart service nginx.

Conclusion

In this blog post, we have shown you how to hide the version number of nginx from the public using two methods: using the server_tokens directive and using a custom error page. Hiding the version number of nginx can help improve your server security by reducing the attack. Surface and preventing information leakage. We hope you found this post useful and informative.

habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Centos Failed Update Kernel

Today I did a kernel update on my server with Centos 7 OS. At the end of the update process, I found a kernel...
habibzain
1 min read

Easy Fix Missing mirrorlist http://mirrorlist.centos.org on CentOS 7

When running yum update or command that utilize the yum system, errors similar to the following are produced: If you’re encountering issues with the...
habibzain
1 min read

Easy Create Laravel Project with Composer

Requirement Laravel, a popular PHP framework, is renowned for its elegant syntax and robust features, making it a top choice for web developers. One...
habibzain
1 min read

Leave a Reply

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

Never miss good article from us, get weekly updates in your inbox