Nginx hides and modifies its version information

Source: Internet
Author: User
After Nginx is installed, its version number is directly displayed by default. for security or privacy reasons, you may need to hide the Nginx version information. Hiding Nginx version information is very simple. you only need to modify a few files to implement it without affecting the running program. Take & ldquo; LNMP one-key installation package & rdquo; as an example. The Nginx Directory of the LNMP one-click package is:/usr/local/nginx.

 

After Nginx is installed, its version number is directly displayed by default. for security or privacy reasons, you may need to hide the Nginx version information. Hiding Nginx version information is very simple. you only need to modify a few files to implement it without affecting the running program.

Take the "LNMP one-click installation package" as an example.

The Nginx Directory of the LNMP one-click package is/usr/local/nginx. we need to modify the Nginx. conf, fastcgi. conf, and fcgi. conf files in the nginx directory. By default, such:


1. modify nginx. conf

In nginx. conf, locate the "http" field ().

 

Add the following parameters in the appropriate position (refer to the figure ):


server_tokens off;

Save it.


II. modify fcgi. conf

Find the following string:


fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

And replace it:


#fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;fastcgi_param  SERVER_SOFTWARE    nginx;

The line "#" indicates the annotator.


3. modify fastcgi. conf

Find the following string:


fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

Replace:


#fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

Save it. The line "#" indicates the annotator.


IV. test that nginx configuration is normal
/usr/local/nginx/sbin/nginx -t

Run the preceding command by using SSH, and the prompt "nginx: configuration file/usr/local/nginx/conf/nginx. conf test is successful" is displayed, indicating no pressure.

Then execute the following command to reload Nginx


service nginx reload

After the heavy load Nginx takes effect, for example, the software that uses the host header detection will not directly display the version number.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.