隱藏Apache、Nginx和PHP的版本號碼的配置方法

來源:互聯網
上載者:User
最近提示說有漏洞,暴露Apache、Nginx和PHP的版本號碼。現在整理下,方法如下:

首先說apache

在http.conf檔案裡添加下面兩行,預設是沒有的

ServerSignature OffServerTokens Prod

ServerSignature出現在Apache所產生的像404頁面、目錄列表等頁面的底部。ServerTokens目錄被用來判斷Apache會在Server HTTP響應包的頭部填充什麼資訊。如果把ServerTokens設為Prod,那麼HTTP響應包頭就會被設定成:Server:Apache

Nginx的版本號碼隱藏有兩地方需要修改

1、nginx.conf 檔案裡的http內部,主要是加上 server_tokens off;

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

2、修改php-fpm的設定檔,需要查看下包含的檔案名稱,預設是fastcgi.conf 檔案。

fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

修改為

fastcgi_param SERVER_SOFTWARE nginx;

3、重啟伺服器就可以了

nginx -s reload

最後說下php的版本隱藏

http的版本資訊一般是暴露在http頭部,一般以類似X-Powered-By: PHP/5.2.11這種形式出現。只需修改php.ini檔案的 expose_php = On 為 expose_php = Off;就可以了。

然後重新載入php

phpfpm reload

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

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.