[FEAT] Default site returns 200 for unknown paths, so nginx-botsearch never matches

未关闭 适合新手
#631 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
docker, nginx
领域
devops, security

调研方向

首先找到示例配置 default.conf,并检查其中的 try_files 指令。检查默认站点如何提供 /,以及建议的 =404 回退是否保留该行为。未知路径返回 404 且 / 仍提供着陆页时即告完成;issue 未指定测试,因此请根据示例配置验证这两种情况。

由索引模型根据 Issue 内容生成。

描述

no-issue-activity
Is this a new feature request?
  • I have searched the existing issues
Wanted change

Hi,

the default site should return 404 for paths that don't exist. Right now it falls back to /index.html and returns 200 for everything.

Reason for change

I wondered why fail2ban never banned the scanners hitting my server. The nginx-botsearch jail only matches requests with a 404:

failregex = ^<HOST> \- \S+ \[\] \"(GET|POST|HEAD) \/<block> \S+\" 404 .+$

But the default site has

try_files $uri $uri/ /index.html /index.htm /index.php$is_args$args;

so every unknown path gets the landing page with 200:

"GET /.ssh/id_rsa HTTP/1.1" 200 1345 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
"GET /%2egitconfig HTTP/2.0" 200 1345 "-" "curl/8.7.1"

In my access log that happened 5282 times, and the jail matched only 21 of 373440 lines. My default.conf is the unchanged sample (2026/03/07).

Proposed code change
try_files $uri $uri/ =404;

/ still shows the index.html. If the fallback is there on purpose (php apps in /config/www), maybe add a comment in the sample that nginx-botsearch doesn't work for the default site then.

主要语言
Dockerfile
星标
3.8k
派生
274
平均合并
25 分钟
30 天内合并 PR
1

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

linuxserver/docker-swag 的其他 Issue

查看 linuxserver/docker-swag 的全部 Issue

相似的 Issue

更多 DevOps Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。