9951 explained code solutions for 126 technologies


nginx-luaHow to return 503 status code


server {
  location / {
    content_by_lua_block {
      ngx.say('error happened')
      ngx.exit(ngx.HTTP_SERVICE_UNAVAILABLE)
    }
  }
}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_SERVICE_UNAVAILABLE

HTTP code 503, see list of available codes