Have instance: Nginx in DMZ with TNT_nginx_upstream_module + Tarantool Cartridge as API server.
When i have response with good result - it's 200 OK + JSON with data
How to set other response?
The Tarantool Nginx upstream module has been designed to follow JSON RPC, not the generic HTTP. There is a way to return arbitrary results, using rewrite_by_lua
in the location
section. It looks like this:
location /api {
default_type application/json;
rewrite_by_lua '
...
';
}
I'm not pasting the full snippet here, as it is quite long. You can look it up here.
In general, I would also advise you to not use the mentioned upstream module if you want a generic HTTP API. It is better to use the HTTP server module written in Lua, and use Nginx as a regular reverse proxy. As a bonus, the Lua HTTP server comes on board of the cartridge module.