前几天,我的网站上发生了一些事情,它吓坏了我,并向我表明我的Apache虚拟主机设置中存在安全漏洞。
我使用的是DotDeb中的php7.0。我正在和我的Debian Jessie进行sudo apt-get upgrade
,由于某种原因,apache的php模块被禁用了。我没有注意到,但结果是我网站上的所有php文件都可以下载!这造成了安全风险,例如,我的数据库密码对我网站的访问者可见。
确保此类事件不会发生的正确配置是什么?例如,如果php不存在,我如何使apache失败?或者任何其他解决方案,不会在这样的事件中将我的php文件提供给我的网站访问者!
以下是我当前的虚拟主机配置。
<VirtualHost *:443>
DocumentRoot /web/root/directory
ServerName www.example.com
<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule>
php_admin_flag engine on
SSLEngine on
SSLProtocol all -SSLv2 -SSLv3
SSLCompression off
SSLCipherSuite AES256+EECDH:AES256+EDH
SSLCertificateFile /path/to/cert.crt
SSLCertificateKeyFile /path/to/key.key
SSLCertificateChainFile /path/to/chain.chn
</VirtualHost>
也许你想要这样的东西?
<Directory />
<IfModule !mod_php7.c>
Deny from all
</IfModule>
</Directory>