Hide Nginx version on Linux and Unix
Use CLI to display the current Nginx version
Nginx will display the version on error pages and in the "Server" response header field. We can verify this using the following command: Example output:
$ curl -I https://your-domain $ curl -I https://www.cyberciti.biz HTTP/2 200 server: nginx/1.17.10 (Ubuntu)date: Tue, 23 Jun 2020 09:36:49 GMTcontent-type: text/html; charset=UTF-8strict-transport-security: max-age=15768000x-whome: l-ncbz01-mg-wg
This is the output of my HTTP/502 error page showing the message:

Use the server_tokens directive to hide the Nginx version
You need to set server_tokens to off to hide the Nginx server version on Linux and Unix-like systems. Edit your nginx.conf file using a text editor such as vim/nano:
We can only set server_tokens in http, server or location context. I will add to my http section: This is what it looks like:
$ sudo vim /etc/nginx/nginx.confserver_tokens off; http { ## Basic Settings ## charset utf-8; sendfile on; tcp_nopush on; tcp_nodelay on; log_not_found off; keepalive_timeout 65; types_hash_max_size 2048; client_max_body_size 16M; include /etc/nginx/mime.types; default_type application/octet-stream; ## Hide Nginx version ## server_tokens off; ## Security headers for Nginx ## add_header Strict-Transport-Security "max-age=15768000" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Xss-Protection "1; mode=block" always; add_header Referrer-Policy strict-origin-when-cross-origin; add_header Feature-policy "accelerometer 'none'; camera 'none'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; payment 'none'; usb 'none'"; add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always; ## SSL Settings ## ssl_protocols TLSv1.3; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## Virtual Host Configs ## include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*;}
Restart or reload the Nginx server normally:
sudo nginx -tsudo nginx -s reload
Verify whether the Nginx version is hidden
Use the curl command as follows: Looking at my Nginx server does not show any version:
$ curl -I https://your-domain-name-here $ curl -I https://www.cyberciti.biz HTTP/2 200 server: nginxdate: Tue, 23 Jun 2020 09:43:17 GMTcontent-type: text/html; charset=UTF-8strict-transport-security: max-age=15768000
Firefox also confirmed that I also successfully hidden the Nginx version:

Other possible values for hiding Nginx version
The syntax is as follows: The default settings on Linux, *BSD and Unix are as follows:
server_tokens on | off | build | string; server_tokens on;
Remove versions from server headers and error pages
We can enable or disable emitting nginx version by changing to the following value:
on: Display the version number.
off: Turn off displaying the version number.
build: Make sure we emit a build name as well as the nginx version. You must have Nginx version 1.11.10.
string: Available for commercial subscriptions only, starting in version 1.9.13, it is possible to use a string with a variable to display the signature and "server" response header field values on the settings error page. An empty string disables emitting of the "server" field.
Set a custom version number in Nginx
For example, commercial subscription (Nginx Plus) users can set it to a fake server version and a custom name: Reload the Nginx server using the service command or the systemctl command: Likewise, test it using the curl command as shown below :
;$ service nginx reload$ curl -I http://127.0.0.1/

Hidden versions are safe in obscurity
Yes, it is security via covert functionality. It is one of the methods of defense in depth. However, it should not be the primary form of defense. You need to write secure code. Install a firewall, especially a WAF (Web Application Firewall). There is no reason to expose the Nginx or PHP or Python version as it could be useful information to an attacker. Keep in mind that Linux/Unix operating systems, web apps/Nginx should remain secure regardless of whether the Nginx version is public or not. However, we do not provide any benefit to attackers by publishing version numbers.
The above is the detailed content of Hide Nginx version on Linux and Unix. For more information, please follow other related articles on the PHP Chinese website!

Windowsispreferredfordesktopcomputingandgamingdueto:1)itsvastsoftwareandgamelibrary,2)user-friendlyandcustomizableinterface,3)extensivehardwarecompatibility,and4)performanceoptimizationcapabilities,despitesomeresource-heavyandupdate-relatedissues.


For years, Linux software distribution relied on native formats like DEB and RPM, deeply ingrained in each distribution's ecosystem. However, Flatpak and Snap have emerged, promising a universal approach to application packaging. This article exami

The differences between Linux and Windows in handling device drivers are mainly reflected in the flexibility of driver management and the development environment. 1. Linux adopts a modular design, and the driver can be loaded and uninstalled dynamically. Developers need to have an in-depth understanding of the kernel mechanism. 2. Windows relies on the Microsoft ecosystem, and the driver needs to be developed through WDK and signed and certified. The development is relatively complex but ensures the stability and security of the system.

The security models of Linux and Windows each have their own advantages. Linux provides flexibility and customizability, enabling security through user permissions, file system permissions, and SELinux/AppArmor. Windows focuses on user-friendliness and relies on WindowsDefender, UAC, firewall and BitLocker to ensure security.

Linux and Windows differ in hardware compatibility: Windows has extensive driver support, and Linux depends on the community and vendors. To solve Linux compatibility problems, you can manually compile drivers, such as cloning RTL8188EU driver repository, compiling and installing; Windows users need to manage drivers to optimize performance.

The main differences between Linux and Windows in virtualization support are: 1) Linux provides KVM and Xen, with outstanding performance and flexibility, suitable for high customization environments; 2) Windows supports virtualization through Hyper-V, with a friendly interface, and is closely integrated with the Microsoft ecosystem, suitable for enterprises that rely on Microsoft software.

The main tasks of Linux system administrators include system monitoring and performance tuning, user management, software package management, security management and backup, troubleshooting and resolution, performance optimization and best practices. 1. Use top, htop and other tools to monitor system performance and tune it. 2. Manage user accounts and permissions through useradd commands and other commands. 3. Use apt and yum to manage software packages to ensure system updates and security. 4. Configure a firewall, monitor logs, and perform data backup to ensure system security. 5. Troubleshoot and resolve through log analysis and tool use. 6. Optimize kernel parameters and application configuration, and follow best practices to improve system performance and stability.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Chinese version
Chinese version, very easy to use
