1

A lua script is being used to look for data stored in redis - it provides some additional processing regarding etags and mime types preventing the basic redis module from being used.

The issue I am experiencing is passing back a 404 error to nginx.conf for error handling. Despite setting status etc. The error does not appear to be caught.

In an ideal world! The following would allow a temporary image to be returned in the event no data can be located in redis.

nginx.conf

location /prefix/ {
  content_by_lua_file conf/redis.lua;
  error_page 404 = /images/not-available.png;
}

redis.lua

...
local arr, error = red:hgetall(uri)
if not arr then
  ngx.log(ngx.ERR, "Redis failed locate uri: "..uri)
  ngx.status = 404
return ngx.exit(ngx.HTTP_NOT_FOUND)  
end
...
4

1 回答 1

0

The issue has been resolved - it was not the 404 handler in the end it was the comparison in the if statement

local arr, error = red:hgetall(uri)
if not arr then

arr appears to be set even if there is a miss - comparing to the value nil resolved the issue.

于 2013-10-10T14:50:48.873 回答