How to hide http header version information in nginx/apache/php

Source: Internet
Author: User

1. How to hide the header version information of nginx

Edit the nginx. conf configuration file and add the following line to http {}:

Copy codeThe Code is as follows: http {
......
Server_tokens off;
......
}

Edit the php-fpm configuration file, fastcgi. conf or fcgi. conf.

Find:

Copy codeThe Code is as follows: fastcgi_param SERVER_SOFTWARE nginx/$ nginx_version;

Changed:

Copy codeThe Code is as follows: fastcgi_param SERVER_SOFTWARE nginx;

Restart nginx to take effect

Copy codeThe Code is as follows: [root @ xmydlinux conf] # curl -- head 127.0.0.1
HTTP/1.1 200 OK
Server: nginx
Content-Type: text/html; charset = UTF-8
Connection: keep-alive
............

2. apache hides the header version information

Edit the httpd. conf file

Find:

Copy codeThe Code is as follows: ServerTokens OS
ServerSignature On

To:Copy codeThe Code is as follows: ServerTokens ProductOnly
ServerSignature Off

Restart the httpd service to take effect.

Copy codeThe Code is as follows: [root @ xmydlinux ~] # Curl-I 127.0.0.1
HTTP/1.1 200 OK
Server: Apache
Accept-Ranges: bytes
Content-Length: 97
Connection: close
Content-Type: text/html

You can also change the file ap_release.h in the include directory of the source code.

Copy codeThe Code is as follows: # define AP_SERVER_BASEVENDOR "Apache Software Foundation" # apache-related words can be changed
# Define AP_SERVER_BASEPROJECT "Apache HTTP Server"
# Define AP_SERVER_BASEPRODUCT "Apache"

# Define AP_SERVER_MAJORVERSION_NUMBER 2 # The version field can be changed at will
# Define AP_SERVER_MINORVERSION_NUMBER 2
# Define AP_SERVER_PATCHLEVEL_NUMBER 17
# Define AP_SERVER_DEVBUILD_BOOLEAN 0

3. PHP version header file hiding and returning

Modify the php. ini file

Find:

Copy codeThe Code is as follows: expose_php = On

To:Copy codeThe Code is as follows: expose_php = Off

You can avoid returning "X-Powered-By: PHP/5.2.17" in the http header ..

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.