如何在 nginx 中不返回错误/error_page 的正文/内容?

sic*_*ckp 3 nginx http-status-code-403 http-status-code-404

如果找不到文件或禁止文件等 - 我真的很想只返回 HTTP 状态代码而不返回正文内容。就像是:

error_page 403 404 body="";
Run Code Online (Sandbox Code Playgroud)

当前(2015 年)的最佳实践是什么?

小智 6

我不确定这是否是最佳实践,但即使没有创建实际的空文件,它仍然有效。

error_page 403 404 /__empty-error-page__.html;

location = /__empty-error-page__.html {
  internal;
  return 200 "";
}
Run Code Online (Sandbox Code Playgroud)