From 9c397a195e00cfb118b7607494ea628a482ceff1 Mon Sep 17 00:00:00 2001 From: samuel-p Date: Fri, 19 Mar 2021 20:33:40 +0100 Subject: [PATCH] some upstream fixes --- nginx.conf.template | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/nginx.conf.template b/nginx.conf.template index 44f84de..102510e 100644 --- a/nginx.conf.template +++ b/nginx.conf.template @@ -24,13 +24,12 @@ server { location /UP { access_by_lua_block{ + local json = require("cjson") ngx.req.read_body() local req = ngx.req.get_body_data() - local newreq, n, err = ngx.re.gsub(req, '\\\\', '\\\\') - local newreq, n, err = ngx.re.gsub(newreq, '"', '\\"') - local newreq, n, err = ngx.re.gsub(newreq, "^", "{\"message\":\"") - local newreq, n, err = ngx.re.gsub(newreq, "$", "\"}") - ngx.req.set_body_data(newreq) + local newreq = { ["message"] = req } + local body = json.encode(newreq) + ngx.req.set_body_data(body) } proxy_set_header Content-Type application/json;