我有关于apache2 web服务器和安全性(也许愚蠢)的问题 – 我试图实现这一点:用户连接从192.168.1.24不会被提示input密码,并允许其他人要求input用户名和密码,如果正确,然后连接。 我正在尝试为整个目录/ var / www做这个
不pipe我把代码放到.htaccess文件还是在httpd.conf中,它都不适用于我。
命令否认,允许 全部否认 AuthName“PassRequest” AuthType基本 AuthUserFile /var/.htpasswd 要求有效的用户 允许从192.168.1.24 满足任何
如果我尝试连接到网页,我允许从允许的IP或任何其他,如果我删除满意的任何行然后我提示input密码,如果我也删除密码,并尝试从不同的IP连接我不是拒绝…有一些模块需要被激活或为什么IP指令被跳过?
它需要放在每个文件夹或/var/www/.htaccess就够了? 我可以把它放在httpd.conf而不是?
我花了最后4个小时试图谷歌为什么这样的行为,任何帮助将高度赞赏:-))
编辑1.11.2012:添加允许覆盖,应用到目录并移动到httpd.conf,没有成功,检查加载模块,问题仍然存在
我添加了AllowOverride指令(虽然目前在/ var / www中没有.htaccess),并将所有内容都放在httpd.conf中的根目录下。
这是我目前在httpd.conf中的
<Directory /> AllowOverride None Order deny,allow Deny from All Allow from 195.137.181.24 Options Indexes AuthType Basic AuthName "You are accessing outside of our network, Enter password!" AuthUserFile /var/.htpasswd Require valid-user Satisfy Any </Directory>
来自apache2ctl -M的加载模块列表:
Loaded Modules: core_module (static) log_config_module (static) logio_module (static) mpm_prefork_module (static) http_module (static) so_module (static) alias_module (shared) auth_basic_module (shared) authn_file_module (shared) authz_default_module (shared) authz_groupfile_module (shared) authz_host_module (shared) authz_user_module (shared) autoindex_module (shared) cgi_module (shared) deflate_module (shared) dir_module (shared) env_module (shared) mime_module (shared) negotiation_module (shared) perl_module (shared) php5_module (shared) python_module (shared) reqtimeout_module (shared) setenvif_module (shared) status_module (shared) Syntax OK
Authz_host模块在那里,所以我没有看到我可以犯的错误。 问题仍然是一样的:当我从IP 195.137.181.24访问我被允许,而不是要求input密码,当我尝试从我的手机通过完全不同的IP访问3G我仍然被允许,而不是提示input密码: – (((
我究竟做错了什么 ? 我没有更多的想法尝试。 任何更多的帮助或build议将不胜感激。 麦克风
我添加了AllowOverride指令(虽然目前在/ var / www中没有.htaccess),并将所有内容都放在httpd.conf中的根目录中。
这是我目前在httpd.conf中的
<Directory /> AllowOverride None Order deny,allow Deny from All Allow from 195.137.181.24 Options Indexes AuthType Basic AuthName "You are accessing outside of our network, Enter password!" AuthUserFile /var/.htpasswd Require valid-user Satisfy Any </Directory>
来自apache2ctl -M的加载模块列表:
Loaded Modules: core_module (static) log_config_module (static) logio_module (static) mpm_prefork_module (static) http_module (static) so_module (static) alias_module (shared) auth_basic_module (shared) authn_file_module (shared) authz_default_module (shared) authz_groupfile_module (shared) authz_host_module (shared) authz_user_module (shared) autoindex_module (shared) cgi_module (shared) deflate_module (shared) dir_module (shared) env_module (shared) mime_module (shared) negotiation_module (shared) perl_module (shared) php5_module (shared) python_module (shared) reqtimeout_module (shared) setenvif_module (shared) status_module (shared) Syntax OK
Authz_host模块在那里,所以我没有看到我可以犯的错误。 问题仍然是一样的:当我从IP 195.137.181.24访问我被允许,而不是要求input密码,当我尝试从我的手机通过完全不同的IP访问3G我仍然被允许,而不是提示input密码: – (((
更新5.11.2012
我发现它–D
在apache2 / sites-enabled是一个隐藏的文件覆盖/ var / www文件夹中的我的指令…愚蠢的我不想早点:-)
首先/你的configuration是正确的,并按我的系统的预期工作。
检查httpd.conf中的AllowOverride指令,如果您确实将mod_authz_host模块加载到apache中…
对于其他问题,您可以像在.htaccess中那样将您的configuration放在Directory指令中,而且甚至是首选。
每个目录的设置都被inheritance到所有的子目录,所以保护根目录就够了。