首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何为子目录设置IP白名单?

问如何为子目录设置IP白名单?
EN

Server Fault用户
提问于 2013-08-27 19:22:10
回答 1查看 15.8K关注 0票数 0

我的一个客户抱怨一次袭击。我检查了访问日志,并从看似随机的IP地址中找到了大量的管理登录页面请求。我在.htacces目录中创建了一个/administrator文件,并使用以下内容填充它(IP地址被混淆):

代码语言:javascript
复制
order deny,allow
deny from all
allow from 96.xxx.xx.xxx #my IP address
allow from 97.xx.xxx.xxx #my client's IP address

然后,我转到一个免费的代理服务器,输入管理页面的URL。该页面没有加载任何资产(图像),但它确实加载了实际页面本身。

乔姆拉!在.htaccess文件中执行DocumentRoot中的一些内容。看起来是这样的:

代码语言:javascript
复制
## Begin - Joomla! core SEF Section.
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the request is for something within the component folder,
# or for the site root, or for an extensionless URL, or the
# requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
#
## End - Joomla! core SEF Section.

我猜想管理员目录中的.htaccess文件不能正常工作的原因与主要的Joomla!.htaccess文件有关。这是真的吗?我尝试将它添加到我的主.htaccess文件中,但是它导致了500个错误:

代码语言:javascript
复制
<Directory /var/www/vhosts/sweathelp.org/httpdocs/administrator>
    order deny,allow
    deny from all
    allow from 96.xxx.xx.xxx
    allow from 97.xx.xxx.xxx
</Directory>

如何有效地阻止对管理员目录的所有访问,不包括两个白色IP地址?

EN

回答 1

Server Fault用户

发布于 2013-08-27 22:53:25

实际的管理员页面(可能是PHP)是吗?存在于此,还是仅仅是由具有假目录结构的index.php生成的呢?

为了简化,可以这样做(在您的主配置文件中,而不是在.htaccess中):

代码语言:javascript
复制
<Location /administrator>
  Order deny,allow
  Deny from all
  Allow from 96.xxx.xx.xxx
  Allow from 97.xx.xxx.xxx
</Location>
票数 3
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/534249

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档