Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

How to set response from rewrite_by_lua_file directive

$
0
0
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?

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>