nginx - 禁用 404 错误日志记录

标签 nginx

在我的配置中,我使用:

error_page  404  /switch;

当我浏览到/testABC 时,我在日志中看到此错误:
open() "/usr/local/nginx/html/www/testABC" failed (2: No such file or directory)

如何禁用此错误?我目前使用 404 作为站点功能的一部分。

最佳答案

如果您不想在 nginx 错误日志中显示 404 错误,log_not_found是您要配置的指令。

默认情况下,log_not_found设置为“on”,这将在主错误日志中报告文件未找到错误。要关闭这些,只需执行以下操作:

log_not_found off;

来源:http://nginx.org/en/docs/http/ngx_http_core_module.html#log_not_found

关于nginx - 禁用 404 错误日志记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20300199/

相关文章:

nginx - 无法让 ab 测试与 gzip 一起使用

nginx - 如何设置 2 个不同的容器在 Kubernetes 中的 2 个不同的 DNS 名称上运行?

SSL 端口与 nginx 和 SNI 统一

nginx - 如何在 nginx 中覆盖全局 auth_basic

ssl - 使用 nginx 配置为我的服务器上的单个目录强制使用 https

nginx - 对 nginx 中的尾部斜杠行为有点困惑

angularjs - 如何创建 AngularJS 应用程序的 Docker 容器?

django - Nginx不提供静态服务

nginx - 如何使用具有 2 个或更多根的 try_files

nginx - 如何在 Debian 服务器的子文件夹中使用 Sphinx 加载文档