应用程序拦截

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. 空指针异常:解决 RequestContextHolder.getRequestAttributes()为空的问题

    现象:实现Feign请求拦截器时,执行如下代码,报空指针异常 ServletRequestAttributes attributes = (ServletRequestAttributes) Requ ...

  2. table标签修改tr,td标签的行距

    修改tr标签的行距,tbale标签的td标签间距 看如下Css文件的代码,其都没有table的tr行距产生效果 tr{ margin-top: 10px; padding: 10px; } td{ m ...

  3. 1.1“Linux操作系统”部署

    ---恢复内容开始--- 1.2.1 版本说明 操作系统版本:CentOS6.5 64位 1.2.2 部署条件说明 无 1.2.3 部署步骤说明 centos6.5 操作系统安装 1.创建虚拟机 2. ...

  4. (三)WCF之契约

    自从我们接收ITOO项目之后,就必须跟WCF打交道,既然必须直面WCF,我就对WCF进行了研究(还不是很深入,是自己目前的理解).之前对WCF的一些基础知识进行了简单的介绍,本篇重点来介绍WCF的契约 ...

  5. Django --- 查询优化,ajax

    目录 ORM查询优化 MTV与MVC模型 choices参数 ajax简介 前后端传输数据编码格式 ajax如何传输json格式数据 ajax如何传入文件数据 序列化 ORM查询优化 在使用数据库数据 ...

  6. matlab的diff()函数

    diff():求差分 一阶差分 X = [1 1 2 3 5 8 13 21]; Y = diff(X) 结果: Y = 0 1 1 2 3 5 8 X = [1 1 1; 5 5 5; 25 25 ...

  7. 关于跨域介绍和djiago解决跨域问题

    什么是跨域? 跨域,指的是浏览器不能执行其他网站的脚本.它是由浏览器的同源策略造成的,是浏览器对javascript施加的安全限制. 什么是同源策略? 同源策略又分为以下两种 DOM同源策略:禁止对不 ...

  8. 关于 or 判断都是Ture的问题

    问题: 1. ret1 = [1, 2, 3, 4] if 11 or 33 in ret1: print("ok") else: print("no") 2. ...

  9. python链接oracle数据库以及数据库的增删改查实例

    初次使用python链接oracle,所以想记录下我遇到的问题,便于向我这样初次尝试的朋友能够快速的配置好环境进入开发环节. 1.首先,python链接oracle数据库需要配置好环境. 我的相关环境 ...

  10. 流媒体知识 wiki

    媒体业务是网络的主要业务之间.尤其移动互联网业务的兴起,在运营商和应用开发商中,媒体业务份量极重,其中媒体的编解码服务涉及需求分析.应用开发.释放license收费等等.最近因为项目的关系,需要理清媒 ...