-
-
Save dangovorenefekt/7ea8a29407815fdab0d75cc14ff4d2b7 to your computer and use it in GitHub Desktop.
Return common errors as json in Nginx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error_page 500 /500.json; | |
location /500.json{ | |
return 500 '{"error": {"status_code": 500,"status": "Internal Server Error"}}'; | |
} | |
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 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 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 408 /408.json; | |
location /408.json{ | |
return 408 '{"error": {"status_code": 408,"status": "Request Timeout}}'; | |
} | |
error_page 418 /418.json; | |
location /418.json{ | |
return 418 '{"error": {"status_code": 418,"status": "I\'m a teapot"}}'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment