Create nginx-json-errors.txt
Config file to be included if you want to return HTTP status codes in JSON format.
This commit is contained in:
191
nginx-json-errors.txt
Normal file
191
nginx-json-errors.txt
Normal file
@@ -0,0 +1,191 @@
|
||||
# This is an NGINX configuration file written and used by me in order to return NGINX HTTP status codes in JSON format, as desired in API contexts.
|
||||
#
|
||||
# (c) Corrado Mulas <tlc@mulas.me>
|
||||
#
|
||||
# For the full copyright and license information, please view the LICENSE
|
||||
# file that was distributed with this source code.
|
||||
|
||||
error_page 400 /400.json;
|
||||
location /400.json{
|
||||
return 400 '{"error": {"status_code": 400,"status": "Bad Request"}}';
|
||||
}
|
||||
|
||||
error_page 401 /401.json;
|
||||
location /401.json{
|
||||
return 401 '{"error": {"status_code": 401,"status": "Unauthorized"}}';
|
||||
}
|
||||
|
||||
error_page 402 /402.json;
|
||||
location /402.json{
|
||||
return 402 '{"error": {"status_code": 402,"status": "Payment Required"}}';
|
||||
}
|
||||
|
||||
error_page 403 /403.json;
|
||||
location /403.json{
|
||||
return 403 '{"error": {"status_code": 403,"status": "Forbidden"}}';
|
||||
}
|
||||
|
||||
error_page 404 /404.json;
|
||||
location /404.json{
|
||||
return 404 '{"error": {"status_code": 404,"status": "Not Found"}}';
|
||||
}
|
||||
|
||||
error_page 405 /405.json;
|
||||
location /405.json{
|
||||
return 405 '{"error": {"status_code": 405,"status": "Method Not Allowed"}}';
|
||||
}
|
||||
|
||||
error_page 406 /406.json;
|
||||
location /406.json{
|
||||
return 406 '{"error": {"status_code": 406,"status": "Not Acceptable"}}';
|
||||
}
|
||||
|
||||
error_page 407 /407.json;
|
||||
location /407.json{
|
||||
return 407 '{"error": {"status_code": 407,"status": "Proxy Authentication Required"}}';
|
||||
}
|
||||
|
||||
error_page 408 /408.json;
|
||||
location /408.json{
|
||||
return 408 '{"error": {"status_code": 408,"status": "Request Timeout}}';
|
||||
}
|
||||
|
||||
error_page 409 /409.json;
|
||||
location /409.json{
|
||||
return 409 '{"error": {"status_code": 409,"status": "Conflict"}}';
|
||||
}
|
||||
|
||||
error_page 410 /410.json;
|
||||
location /410.json{
|
||||
return 410 '{"error": {"status_code": 410,"status": "Gone"}}';
|
||||
}
|
||||
|
||||
error_page 411 /411.json;
|
||||
location /411.json{
|
||||
return 411 '{"error": {"status_code": 411,"status": "Length Required"}}';
|
||||
}
|
||||
|
||||
error_page 412 /412.json;
|
||||
location /412.json{
|
||||
return 412 '{"error": {"status_code": 412,"status": "Precondition Failed"}}';
|
||||
}
|
||||
|
||||
error_page 413 /413.json;
|
||||
location /413.json{
|
||||
return 413 '{"error": {"status_code": 413,"status": "Payload Too Large"}}';
|
||||
}
|
||||
|
||||
error_page 414 /414.json;
|
||||
location /414.json{
|
||||
return 414 '{"error": {"status_code": 414,"status": "URI Too Long"}}';
|
||||
}
|
||||
|
||||
error_page 415 /415.json;
|
||||
location /415.json{
|
||||
return 415 '{"error": {"status_code": 415,"status": "Unsupported Media Type"}}';
|
||||
}
|
||||
|
||||
error_page 416 /416.json;
|
||||
location /416.json{
|
||||
return 416 '{"error": {"status_code": 416,"status": "Range Not Satisfiable"}}';
|
||||
}
|
||||
|
||||
error_page 417 /417.json;
|
||||
location /417.json{
|
||||
return 417 '{"error": {"status_code": 417,"status": "Expectation Failed"}}';
|
||||
}
|
||||
|
||||
error_page 418 /418.json;
|
||||
location /418.json{
|
||||
return 418 '{"error": {"status_code": 418,"status": "I\'m a teapot"}}';
|
||||
}
|
||||
|
||||
error_page 420 /420.json;
|
||||
location /420.json{
|
||||
return 420 '{"error": {"status_code": 420,"status": "Enhance your calm"}}';
|
||||
}
|
||||
|
||||
error_page 422 /422.json;
|
||||
location /422.json{
|
||||
return 422 '{"error": {"status_code": 422,"status": "Unprocessable Entity"}}';
|
||||
}
|
||||
|
||||
error_page 423 /423.json;
|
||||
location /423.json{
|
||||
return 423 '{"error": {"status_code": 423,"status": "Locked"}}';
|
||||
}
|
||||
|
||||
error_page 424 /424.json;
|
||||
location /424.json{
|
||||
return 424 '{"error": {"status_code": 424,"status": "Failed Dependency"}}';
|
||||
}
|
||||
|
||||
error_page 426 /426.json;
|
||||
location /426.json{
|
||||
return 426 '{"error": {"status_code": 426,"status": "Upgrade Required"}}';
|
||||
}
|
||||
|
||||
error_page 428 /428.json;
|
||||
location /428.json{
|
||||
return 428 '{"error": {"status_code": 428,"status": "Precondition Required"}}';
|
||||
}
|
||||
|
||||
error_page 429 /429.json;
|
||||
location /429.json{
|
||||
return 429 '{"error": {"status_code": 429,"status": "Too Many Requests"}}';
|
||||
}
|
||||
|
||||
error_page 431 /431.json;
|
||||
location /431.json{
|
||||
return 431 '{"error": {"status_code": 431,"status": "Request Header Fields Too Large"}}';
|
||||
}
|
||||
|
||||
error_page 451 /451.json;
|
||||
location /451.json{
|
||||
return 451 '{"error": {"status_code": 451,"status": "Unavailable For Legal Reasons"}}';
|
||||
}
|
||||
|
||||
error_page 500 /500.json;
|
||||
location /500.json{
|
||||
return 500 '{"error": {"status_code": 500,"status": "Internal Server Error"}}';
|
||||
}
|
||||
|
||||
error_page 501 /501.json;
|
||||
location /501.json{
|
||||
return 501 '{"error": {"status_code": 501,"status": "Not Implemented"}}';
|
||||
}
|
||||
error_page 502 /502.json;
|
||||
location /502.json{
|
||||
return 502 '{"error": {"status_code": 502,"status": "Bad Gateway"}}';
|
||||
}
|
||||
|
||||
error_page 503 /503.json;
|
||||
location /503.json{
|
||||
return 503 '{"error": {"status_code": 503,"status": "Service Temporarily Unavailable"}}';
|
||||
}
|
||||
|
||||
error_page 504 /504.json;
|
||||
location /504.json{
|
||||
return 504 '{"error": {"status_code": 504,"status": "Gateway Timeout"}}';
|
||||
}
|
||||
|
||||
error_page 505 /505.json;
|
||||
location /505.json{
|
||||
return 505 '{"error": {"status_code": 505,"status": "HTTP Version Not Supported"}}';
|
||||
}
|
||||
|
||||
error_page 506 /506.json;
|
||||
location /506.json{
|
||||
return 506 '{"error": {"status_code": 506,"status": "Variant Also Negotiates"}}';
|
||||
}
|
||||
|
||||
error_page 507 /507.json;
|
||||
location /507.json{
|
||||
return 507 '{"error": {"status_code": 507,"status": "Insufficient Storage"}}';
|
||||
}
|
||||
|
||||
error_page 511 /511.json;
|
||||
location /511.json{
|
||||
return 511 '{"error": {"status_code": 511,"status": "Network Authentication Required"}}';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user