Jacky's Blog Jacky's Blog
  • 首页
  • 关于
  • 项目
  • 大事记
  • 留言板
  • 友情链接
  • 分类
    • 干货
    • 随笔
    • 项目
    • 公告
    • 纪念
    • 尝鲜
    • 算法
    • 深度学习
  • 2
  • 0

Nginx 错误页面 JSON

Jacky
18 5 月, 2021

保存在 error_json.conf 中,然后在其他配置文件中使用 include 引入。

 error_page 500 /500.json;
 location /500.json {
     return 500 '{"status_code":500,"message":"Internal Server Error"}';
 }

 error_page 502 /502.json;
 location /502.json {
     return 502 '{"status_code":502,"message":"Bad Gateway"}';
 }

 error_page 503 /503.json;
 location /503.json {
     return 503 '{"status_code":503,"message":"Service Temporarily Unavailable"}';
 }

 error_page 504 /504.json;
 location /504.json {
     return 504 '{"status_code":504,"message":"Gateway Timeout"}';
 }

 error_page 400 /400.json;
 location /400.json {
     return 400 '{"status_code":400,"message":"Bad Request"}';
 }

 error_page 401 /401.json;
 location /401.json {
     return 401 '{"status_code":401,"message":"Unauthorized"}';
 }

 error_page 403 /403.json;
 location /403.json {
     return 403 '{"status_code":403,"message": "Forbidden"}';
 }

 error_page 404 /404.json;
 location /404.json {
     return 404 '{"status_code":404,"message":"Not Found"}';
 }

 error_page 408 /408.json;
 location /408.json {
     return 408 '{"status_code":408,"message":"Request Timeout}';
 }

 error_page 418 /418.json;
 location /418.json {
     return 418 '{"status_code":418,"message":"I\'m a teapot"}';
 }
2
本文系作者 @Jacky 原创发布在 Jacky's Blog。未经许可,禁止转载。
记一次服务器无响应的排查
上一篇
私钥登录 SSH
下一篇

评论 (0)

再想想
暂无评论

近期评论

  • Jacky 发表在《Nginx UI》
  • kim 发表在《Nginx UI》
  • Jacky 发表在《留言板》
  • 菜鸟 发表在《留言板》
  • merlin 发表在《留言板》
2
Copyright © 2016-2025 Jacky's Blog. Designed by nicetheme.
粤ICP备16016168号-1
  • 首页
  • 关于
  • 项目
  • 大事记
  • 留言板
  • 友情链接
  • 分类
    • 干货
    • 随笔
    • 项目
    • 公告
    • 纪念
    • 尝鲜
    • 算法
    • 深度学习

搜索

  • Mac
  • Apple
  • OS X
  • iOS
  • macOS
  • Linux
  • 阿里云
  • WordPress
  • 运维
  • macOS Sierra

Jacky

Go Python C C++ | 弱冠之年 | 物联网工程
183
文章
193
评论
267
喜欢