I have a rewrite_by_lua_file directive where I lookup a key supplied as a header in the original request, in a shared lookup table. If found, I pass as a header the value mapped to the original key. If not, I return a specific status code.
So in my nginx.conf file I have something like this:
location /start
{
rewrite_by_lua_file key_lookup.lua;
proxy_pass http://127.0.0.1:8080/start;
}
And my key_lookup.lua is attached.
So I am trying to use ngx.say to set the response body to a specific JSON content when I return 401 Unauthorized, with no luck (the status code returned is what I expect, but the response body is empty). I have also tried using ngx.print.
Is there another way to achieve this?
So in my nginx.conf file I have something like this:
location /start
{
rewrite_by_lua_file key_lookup.lua;
proxy_pass http://127.0.0.1:8080/start;
}
And my key_lookup.lua is attached.
So I am trying to use ngx.say to set the response body to a specific JSON content when I return 401 Unauthorized, with no luck (the status code returned is what I expect, but the response body is empty). I have also tried using ngx.print.
Is there another way to achieve this?