如何在Apache2中仅允许localhost?
我的/ etc / apache2 / sites-enabled / 000-default是
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /home/masi/Dropbox/a
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/masi/Dropbox/a/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
deny from all // Problem HERE!
allow from 127.0.0.1
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
我浏览到
http://localhost/index.php
失败。我得到Forbidden
。
最佳答案
切换您的允许,拒绝顺序(您要先拒绝所有,然后允许本地主机)。
更改:
Order allow,deny
至:
Order deny,allow
(这是默认行为)
关于apache - 在Apache 000-default中仅允许localhost,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1250055/