2808 explained code solutions for 75 technologies


nginx-luaHow to return 404 status code


server {
  location / {
    content_by_lua_block {
      ngx.say('not found')
      ngx.exit(ngx.HTTP_NOT_FOUND)
    }
  }
}ctrl + c
content_by_lua_block

nginx-lua module directive to specify block of Lua code

ngx.say

output given text to client

ngx.exit

end response with specified status code

ngx.HTTP_NOT_FOUND

HTTP code 402, see list of available codes