error_page 400 = @400; location @400 { return 400 '{"status":400,"message":"Bad request"}\n'; } error_page 401 = @401; location @401 { return 401 '{"status":401,"message":"Unauthorized"}\n'; } error_page 403 = @403; location @403 { return 403 '{"status":403,"message":"Forbidden"}\n'; } error_page 404 = @404; location @404 { return 404 '{"status":404,"message":"Resource not found"}\n'; }