【发布时间】:2021-03-12 11:00:07
【问题描述】:
我正在尝试限制对托管在 OpenBSD 的 httpd 本机服务器上的简单网站的某些子文件夹的访问。配置比较简单,仅供测试:
server "10.0.1.222" {
listen on 10.0.1.222 port 80
log style combined
location "/*php*"{
root "/FOLDER"
fastcgi socket "/run/php-fpm.sock"
}
directory {
index "index.php"
}
location "/*" {
root "/FOLDER"
}
location "/SUBFOLDER/*" {block}
}
在SUBFOLDER 中我放置了一些不打算直接查看的html。
使用最后一个 location 指令,我希望像 http://10.0.1.222/SUBFOLDER/01.html 这样的请求会被 403 代码阻止,但我无法实现。
虽然 http://10.0.1.222/SUBFOLDER/ 返回 access denied,但在 SUBFOLDER 中请求任何正确的 html 文档名称可以满足该请求而不会引起任何投诉。
如果字符串:/SUBFOLDER/* 是(我认为)正确的 shell glob,它应该匹配字符串 /SUBFOLDER/ 本身 + 之后给出的任何字符串,那么像 http://10.0.1.222/SUBFOLDER/01.html 这样的请求应该返回代码 403。但它不起作用。
我尝试了很多组合:"/SUBFOLDER/*"、"/SUBFOLDER/*.html" 等等,有或没有前导 /。没有效果。
可能有一些我不明白的地方,但我无法调试我的错误。 我错过了什么?
【问题讨论】:
标签: apache location block httpd.conf openbsd