File tree Expand file tree Collapse file tree 2 files changed +52
-1
lines changed
Expand file tree Collapse file tree 2 files changed +52
-1
lines changed Original file line number Diff line number Diff line change 1+ # How to use in Caddy
2+
3+ This setup allows you to serve ** custom error pages** in your Caddy server configuration using reusable ** snippets** for both:
4+
5+ - ** Upstream response errors** (e.g. Not found errors)
6+ - ** General proxy/server errors** (e.g. Caddy-level issues)
7+
8+ ## 📁 Error Pages
9+ Download the ZIP from [ README.md] ( ./README.md ) and extract all html files into /errors (or anyo ther directory)
10+
11+ ## 📦 Snippets
12+ Add the following two snippets at the top of your ` Caddyfile ` :
13+
14+ ``` caddyfile
15+ (upstream_error_handler) {
16+ @error status 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 500 501 502 503 504 505 506 507 508 509 510 511
17+ handle_response @error {
18+ root * /errors
19+ rewrite * /http-{rp.status_code}.html
20+ templates
21+ file_server
22+ }
23+ }
24+
25+ (proxy_error_handler) {
26+ handle_errors {
27+ root * /errors
28+ rewrite * /http-{err.status_code}.html
29+ templates
30+ file_server
31+ }
32+ }
33+ ```
34+
35+ ⚠️ Using ** ` templates ` ** can leak information such as internal URLs or IPs! USE WITH CAUTION!
36+ ⚠️ Depending on your error directory, you might have to change the ` root ` directive in the Snippets!
37+
38+ ## 🛠 How to Use
39+ Add the following imports into your ` handler ` or ` reverse_proxy ` blocks
40+
41+ ``` caddyfile
42+ example.com {
43+ import proxy_error_handler # Handles errors caused by the proxy (e.g. includes 501)
44+
45+ reverse_proxy http://localhost:8080 {
46+ import upstream_error_handler # Handles errors caused / returned from upstream
47+ }
48+ }
49+ ```
Original file line number Diff line number Diff line change 77## 📁 Download
88Download the latest bundle from GitHub Pages Branch: [ Download as ZIP] ( https://github.com/ToBiDi0410/error-pages/archive/refs/heads/gh-pages.zip )
99
10- ---
10+
11+ ## 🛠 Usage
12+ - [ How to use in Caddy] ( ./CADDY.md )
1113
1214## 🌐 Available Pages & Demo
1315Here's a list of all available error pages and their demo links:
You can’t perform that action at this time.
0 commit comments