更新:
我在 body_filter_by_lua 模块中添加了以下代码:
local tbl = {}
tbl["h"] = "a"
ngx.arg[1] = cjson.encode(tbl)
原生的 ngx.arg[1] 是个 JSON 字符串,现在我构造了一个 JSON 字符串,赋值给 ngx.arg[1],但是却不能正常的返回到客户端。
请教一下这到底是什么原因呢?我怎么样才能修改 proxy_pass 之后返回给客户的的 response 呢?
在 2016年1月27日星期三 UTC+8下午6:19:24,hao dong写道:
hi all,
我的 nginx.conf 使用了 proxy_pass 命令,现在有一个 upstream,总是请求超时。当然 nginx 自己生成了一个 response 给我,body 是这样的
<html>
<head><title>504 Gateway Time-out</title></head>
<body bgcolor="white">
<center><h1>504 Gateway Time-out</h1></center>
<hr><center>openresty/
1.9.3.2<
/center></body>
</html>
我现在想做个比较友好的 response 给客户端,比如一个 json 字符串 {"ret":110, "err":"timeout"}
请教各位,有什么比较好的方法能做到吗?