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

Nginx 错误页面 JSON

Jacky
5月 18, 2021干货阅读 624

保存在 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"}';
 }
赞(1)
本文系作者 @Jacky 原创发布在 Jacky's Blog。未经许可,禁止转载。
记一次服务器无响应的排查
上一篇
私钥登录 SSH
下一篇
再想想
暂无评论
近期评论
  • Jacky发表在《Nginx UI》
  • daiwenzh5发表在《Nginx UI》
  • Jacky发表在《Nginx UI》
  • daiwenzh5发表在《Nginx UI》
  • Jacky发表在《Nginx UI》
1
  • 1
  • 0
Copyright © 2016-2023 Jacky's Blog. Designed by nicetheme.
粤ICP备16016168号-1
  • 首页
  • 关于
  • 项目
  • 大事记
  • 留言板
  • 友情链接
  • 分类
    • 干货
    • 随笔
    • 项目
    • 公告
    • 纪念
    • 尝鲜
    • 算法
    • 深度学习
# Mac # # Apple # # OS X # # iOS # # macOS #
Jacky
PHP C C++ Python | 舞象之年 | 物联网工程
174
文章
169
评论
267
喜欢