Created
February 17, 2016 22:58
-
-
Save mjmeyer/6cf8d3c1199d028f0921 to your computer and use it in GitHub Desktop.
Http.cat erorr pages for 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
# ---------- 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/; | |
} |
And thanks for this, it's amazing ❤
Use the command
tail -f /var/log/nginx/error.log
to watch for errors when setting this up.If you get a lot of
SSL_do_handshake() failed
errors and then onerewrite or internal redirection cycle while internally redirecting to "/status-cats-error.html"
on every request, you need to addproxy_ssl_server_name on;
to thehttp-cat-error-pages.conf
config file. I added mine below line 12, so the file looks like this:[...]
# 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; proxy_ssl_server_name on; # https://stackoverflow.com/a/49116797/8483877 # 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;
[...]
Thanks, this fixed this exact issue I was having. Didn't used to happen until this year I think, I just never noticed it was broken.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use the command
tail -f /var/log/nginx/error.log
to watch for errors when setting this up.If you get a lot of
SSL_do_handshake() failed
errors and then onerewrite or internal redirection cycle while internally redirecting to "/status-cats-error.html"
on every request, you need to addproxy_ssl_server_name on;
to thehttp-cat-error-pages.conf
config file. I added mine below line 12, so the file looks like this:[...]
[...]
Source: https://stackoverflow.com/a/49116797/8483877