You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

配置Server块后NGINX仍返回404错误的技术求助

解决NGINX访问/AD/notifications返回404的问题

你的配置核心问题出在root指令的使用逻辑上:当location匹配/AD/notifications时,root /html会让NGINX尝试读取/html/AD/notifications/about.html,但你的about.html实际在/html目录下,所以必然返回404。

解决方法有两种,推荐第一种:

方案一:替换root为alias

修改location块配置:

location /AD/notifications {
    alias /html;
    index about.html;
}

alias会直接将匹配的路径替换为指定目录,NGINX会去/html下查找about.html,完全匹配你的文件结构。

方案二:调整路径匹配与文件位置(不推荐)

如果坚持用root,需要在/html下创建AD/notifications目录,把about.html移进去,同时保持原配置不变。但这种方式需要调整现有文件结构,不如方案一简洁。

修改配置后,执行nginx -s reload重新加载配置,再访问http://localhost:8000/AD/notifications即可正常访问。

内容的提问来源于stack exchange,提问作者Zachary Godwin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 11:28:18