应用程序拦截

nginx 拦截 保证 接口返回

https://serverfault.com/questions/859667/configure-nginx-how-to-handle-500-error-on-upstream-itself-while-nginx-handle

proxy_intercept_errors

http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_intercept_errors

    server {
listen 8003 default_server;
set $rip $remote_addr;
set $x_request_trace_dump_this trace-id-host@$host-pid@$pid-connection@$connection-bytes_sent@$bytes_sent-msec@$msec-remote_addr@$rip;
proxy_temp_file_write_size 102400k;
location @fallback {
return 500 '{"status":500,"data":[],"msg":"please call admin..."}';
}
location / {
proxy_intercept_errors on;
error_page 500 502 503 504 = @fallback;
gzip on;
gzip_proxied any;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Request-Trace-Dump $trace;
if ($http_x_request_trace_dump = '') {
set $x_request_trace_dump_that '';
}
set $x_request_trace_dump_that $http_x_request_trace_dump;
set $trace $x_request_trace_dump_that@@$x_request_trace_dump_this;
proxy_pass http://127.0.0.1:8004/;
}
}

  

configure-nginx-how-to-handle-500-error-on-upstream-itself-while-nginx-handle 自定义header 传递header 定义拦截器的更多相关文章

  1. nginx停止后再启动出现: [error] open() "/usr/local/nginx/logs/nginx.pid" failed错误的解决方法

    为了备份数据 手动停止了服务器的nginx 结果启动时报错 nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" fail ...

  2. f-stack中nginx配置后make出现error: ignoring return value of ‘ftruncate’

    问题 Nginx 配置后 make 出现error: src/os/unix/ngx_process_cycle.c: In function 'ngx_start_worker_processes' ...

  3. 【yii2从Apache迁移到nginx上访问报500错误】

    [yii2从Apache迁移到nginx上访问报500错误] 今天迁移yii2项目从Apache到nginx,出现了几个小问题,记录一下 index.php 加上 error_reporting(E_ ...

  4. nginx的报错500

    500:服务器内部错误,也就是服务器遇到意外情况,而无法履行请求. 500错误一般有几种情况: 1. web脚本错误,如php语法错误,lua语法错误等. 2. 访问量大的时候,由于系统资源限制,而不 ...

  5. 记一次接口调试错误: {"timestamp":"2019-09-11T03:04:30.036+0000","status":500,"error":"Internal Server Error","message":"Could not write JSON: Object is null; nested exception is com.fasterxml.jackson

    接口测试中用postman测试返回是正常的,但是使用其他人去调用就出错了,找了半天,才想起来使用了nginx,用于端口的代理转发.然后根据错误信息发现json格式的某个字段为null,结合日志中的报文 ...

  6. Nginx nginx: [emerg] using regex "\.php$" requires PCRE library 或 编译nginx错误:make[1]: *** [/pcre//Makefile] Error 127

    nginx: [emerg] using regex "\.php$" requires PCRE library  或 编译nginx错误:make[1]: *** [/pcre ...

  7. HTTP Status 500 - Error instantiating servlet class cn.it.bd.S011

    HTTP Status 500 - Error instantiating servlet class cn.it.bd.S011 出现此报错的很大可能是因为 <servlet-class> ...

  8. servlet程序HTTP Status 500 - Error instantiating servlet class 解决

    在eclipase 中编译 servlet  但是一致报 HTTP Status 500 - Error instantiating servlet class XXX类 的问题 , 解决方法 1. ...

  9. 转载:configure执行流程(1.5.2)《深入理解Nginx》(陶辉)

    原文:https://book.2cto.com/201304/19619.html 我们看到configure命令支持非常多的参数,读者可能会好奇它在执行时到底做了哪些事情,本节将通过解析confi ...

  10. tomcat已启动,使用maven的deploy发布后,根据路径打开浏览器访问时报错HTTP Status 500 - Error instantiating servlet class

    web项目中请求出现错误,如下: HTTP Status 500 - Error instantiating servlet class XXXX类 type Exception report mes ...

随机推荐

  1. Android笔记(三十九) Android中的数据存储——SQLite(一) create

    SQLite是内置于Android的一款轻量级关系型数据库,她运算速度快,占用资源少,通常只需要几百K的内存就足够了,因而特别适合在移动设备上使用. SQLite不仅支持标准的SQL语法,还遵循数据库 ...

  2. python之变量的数据类型(3)dict 及解构简单介绍

    一.变量的数据类型(3) 1. dict 字典dict 用{}来表示 键值对数据 {key:value} 唯一性 键 都必须是可哈希的 不可变的数据类型就可以当做字典中的键 值 没有任何限制 2.增删 ...

  3. SSH安全协议

    SSHD服务 介绍:SSH 协议:安全外壳协议.为 Secure Shell 的缩写.SSH 为建立在应用层和传输层基础上的安全协议. 默认端口22 作用 sshd服务使用SSH协议可以用来进行远程控 ...

  4. Beta版本冲刺

    一.团队成员 团队名称 西柚排课王 项目名称 易奇排排课系统 团队成员 秦傲明 201731062308 韩浩 201731062319 黄青松 201731062322 王越豪 2017310623 ...

  5. 智能驾驶数据后处理分析利器—INTEWORK-VDA

            随着智能驾驶技术在新车上逐步普及,车辆研发阶段需要做大量的实车测试工作,当前的测试方式主要是路采实车数据后,按标准和法规进行测试场景提取和测试数据分析.调查显示绝大部分智能驾驶研发厂商 ...

  6. 2019-2020-1 20199301《Linux内核原理与分析》第五周作业

    第四章·系统调用的三层机制(上) 本章的重点在于用户态程序如何触发系统调用? 一.用户.内核.中断 IntelX86有四种不同的执行级别.Linux操作系统中只采用了其中的0和3两个特权级别,分别对应 ...

  7. 【Python】编程小白的第一本python(最基本的魔法函数)

    Python官网中各个函数介绍的链接:https://docs.python.org/3/library/functions.html 几个常见的词: def (即 define,定义)的含义是创建函 ...

  8. MyEclipse激活代码

    package TestCase; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStr ...

  9. 做vue项目时,收集的一些有意思的功能

    1. element-ui dialog组件添加可拖拽位置 可拖拽宽高 https://segmentfault.com/a/1190000012940145

  10. LightOJ - 1282 - Leading and Trailing(数学技巧,快速幂取余)

    链接: https://vjudge.net/problem/LightOJ-1282 题意: You are given two integers: n and k, your task is to ...