隐藏Apache、Nginx和PHP的版本号的配置方法

WBOY
Release: 2016-06-20 12:25:39
Original
936 people have browsed it

最近提示说有漏洞,暴露Apache、Nginx和PHP的版本号。现在整理下,方法如下:

首先说apache

在http.conf文件里添加下面两行,默认是没有的

ServerSignature OffServerTokens Prod
Copy after login

ServerSignature出现在Apache所产生的像404页面、目录列表等页面的底部。ServerTokens目录被用来判断Apache会在Server HTTP响应包的头部填充什么信息。如果把ServerTokens设为Prod,那么HTTP响应包头就会被设置成:Server:Apache

Nginx的版本号隐藏有两地方需要修改

1、nginx.conf 文件里的http内部,主要是加上 server_tokens off;

http {    # ...省略一些配置    server_tokens off;  }
Copy after login

2、修改php-fpm的配置文件,需要查看下包含的文件名,默认是fastcgi.conf 文件。

fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
Copy after login

修改为

fastcgi_param SERVER_SOFTWARE nginx;
Copy after login

3、重启服务器就可以了

nginx -s reload
Copy after login

最后说下php的版本隐藏

http的版本信息一般是暴露在http头部,一般以类似X-Powered-By: PHP/5.2.11这种形式出现。只需修改php.ini文件的 expose_php = On 为 expose_php = Off;就可以了。

然后重新加载php

phpfpm reload
Copy after login

本文永久更新链接地址: http://www.linuxidc.com/Linux/2016-06/132342.htm

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!