应用程序拦截

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. nginx_status

    server { listen ; server_name blog.oldboy.com; root /code/wordpress; index index.php index.html; loc ...

  2. 随Linux开机自动启动mysql

    在MySQL的管理过程中,会遇到PC Server脱机或者重启,我需要在主机启动后再将MySQL服务启动.如果上百台或者更多的MySQL主机进行维护时,可能会有多台主机出现类似问题,要是每次都手动操作 ...

  3. React系列,jsx

    <script type="text/babel"> var name = "kimoo"; var fn = ()=> "kimo ...

  4. Beta版本冲刺

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

  5. windows系统开机执行文件

    以下都是在windows系统下执行的 开机自启程序 新建xxx.bat的文件 编辑自己的bat文件,将所要加载的项目引导进来 注意: 如果有相对路径的话,就需要先加载项目,在用python 执行脚本程 ...

  6. Linux 永久改变系统时间

    Centos系统,必须同时修改系统时间和硬件时间,才可以保证修改有效,单纯的使用date命令修改系统时间,是立即生效,重启后系统还原.具体操作如下: 1.date {查看目前本地的时间}2.hwclo ...

  7. error: invalid-first-character-of-tag-name错误解决方案

    HTML 特殊字符写法要用原始码,例如: ‘<’ 原始码为 < ‘>’ 原始码为 > 解决示例: 原错误代码 <div><</div> 修改后代码 ...

  8. No converter found capable of converting from type [java.lang.String] to type [java.util.Map<java.lang.String, java.lang.String>]

    java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.conte ...

  9. Caused by: java.lang.IllegalStateException: Ambiguous mapping found

    Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map ‘myCockpitMgrControl ...

  10. 1219 Vue项目创建及基础

    目录 vue项目 1. 项目创建 cmd创建 可视化创建 2. 项目启动 vue重新构建依赖 pycharm管理vue项目 3. 项目目录介绍 index.html index.js App.vue ...