Instantly share code, notes, and snippets.

Embed
What would you like to do?
Http.cat erorr pages for nginx
# ---------- Status Cats Error Pages!!! via: https://http.cat/ ---------
#
# requires that a dns resolver be set for nginx as in: resolver 127.0.0.1;
# typically uses dnsmasq for 127.0.0.1 resolver
#
# Usage:
# place this file somewhere accessible to nginx. /etc/nginx/snippets is a decent choice.
# then inside the server block(s) you want cat themed error status responses do:
# include snippets/http-cat-error-pages.conf
#
recursive_error_pages on;
# all of the status defined at http.cat AND allowed by nginx to be error_page'd
#
error_page 300 301 302 303 304 305 307 400 401 402 403 404 405 406 408 409 410 411 412 413 414 415 416 417 418 420 422 423 424 425 426 429 431 444 450 451 500 501 502 503 506 507 508 509 599 /status-cats-error.html;
location /status-cats-error.html {
proxy_pass https://http.cat/$status;
}
# nginx wont let you use statuses < 300 in return stmts or in error_page stmts, so provide a
# proxied location to test those....
#
location ~ ^/test-status-cats/(?<cat>.*)$ {
proxy_pass https://http.cat/$cat/;
}
@mattusey

This comment has been minimized.

Show comment
Hide comment
@mattusey

mattusey commented Feb 18, 2016

Genius!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment