-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
httpcaddyfile: Add optional status code argument to
handle_errors
d…
…irective (#5965) Co-authored-by: Aziz Rmadi <azizrmadi@Azizs-MacBook-Air.local>
- Loading branch information
1 parent
5e2f1b5
commit 4181c79
Showing
8 changed files
with
942 additions
and
2 deletions.
There are no files selected for viewing
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
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
245 changes: 245 additions & 0 deletions
245
caddytest/integration/caddyfile_adapt/error_multi_site_blocks.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,245 @@ | ||
foo.localhost { | ||
root * /srv | ||
error /private* "Unauthorized" 410 | ||
error /fivehundred* "Internal Server Error" 500 | ||
|
||
handle_errors 5xx { | ||
respond "Error In range [500 .. 599]" | ||
} | ||
handle_errors 410 { | ||
respond "404 or 410 error" | ||
} | ||
} | ||
|
||
bar.localhost { | ||
root * /srv | ||
error /private* "Unauthorized" 410 | ||
error /fivehundred* "Internal Server Error" 500 | ||
|
||
handle_errors 5xx { | ||
respond "Error In range [500 .. 599] from second site" | ||
} | ||
handle_errors 410 { | ||
respond "404 or 410 error from second site" | ||
} | ||
} | ||
---------- | ||
{ | ||
"apps": { | ||
"http": { | ||
"servers": { | ||
"srv0": { | ||
"listen": [ | ||
":443" | ||
], | ||
"routes": [ | ||
{ | ||
"match": [ | ||
{ | ||
"host": [ | ||
"foo.localhost" | ||
] | ||
} | ||
], | ||
"handle": [ | ||
{ | ||
"handler": "subroute", | ||
"routes": [ | ||
{ | ||
"handle": [ | ||
{ | ||
"handler": "vars", | ||
"root": "/srv" | ||
} | ||
] | ||
}, | ||
{ | ||
"handle": [ | ||
{ | ||
"error": "Internal Server Error", | ||
"handler": "error", | ||
"status_code": 500 | ||
} | ||
], | ||
"match": [ | ||
{ | ||
"path": [ | ||
"/fivehundred*" | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"handle": [ | ||
{ | ||
"error": "Unauthorized", | ||
"handler": "error", | ||
"status_code": 410 | ||
} | ||
], | ||
"match": [ | ||
{ | ||
"path": [ | ||
"/private*" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"terminal": true | ||
}, | ||
{ | ||
"match": [ | ||
{ | ||
"host": [ | ||
"bar.localhost" | ||
] | ||
} | ||
], | ||
"handle": [ | ||
{ | ||
"handler": "subroute", | ||
"routes": [ | ||
{ | ||
"handle": [ | ||
{ | ||
"handler": "vars", | ||
"root": "/srv" | ||
} | ||
] | ||
}, | ||
{ | ||
"handle": [ | ||
{ | ||
"error": "Internal Server Error", | ||
"handler": "error", | ||
"status_code": 500 | ||
} | ||
], | ||
"match": [ | ||
{ | ||
"path": [ | ||
"/fivehundred*" | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"handle": [ | ||
{ | ||
"error": "Unauthorized", | ||
"handler": "error", | ||
"status_code": 410 | ||
} | ||
], | ||
"match": [ | ||
{ | ||
"path": [ | ||
"/private*" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"terminal": true | ||
} | ||
], | ||
"errors": { | ||
"routes": [ | ||
{ | ||
"match": [ | ||
{ | ||
"host": [ | ||
"foo.localhost" | ||
] | ||
} | ||
], | ||
"handle": [ | ||
{ | ||
"handler": "subroute", | ||
"routes": [ | ||
{ | ||
"handle": [ | ||
{ | ||
"body": "404 or 410 error", | ||
"handler": "static_response" | ||
} | ||
], | ||
"match": [ | ||
{ | ||
"expression": "{http.error.status_code} in [410]" | ||
} | ||
] | ||
}, | ||
{ | ||
"handle": [ | ||
{ | ||
"body": "Error In range [500 .. 599]", | ||
"handler": "static_response" | ||
} | ||
], | ||
"match": [ | ||
{ | ||
"expression": "{http.error.status_code} \u003e= 500 \u0026\u0026 {http.error.status_code} \u003c= 599" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"terminal": true | ||
}, | ||
{ | ||
"match": [ | ||
{ | ||
"host": [ | ||
"bar.localhost" | ||
] | ||
} | ||
], | ||
"handle": [ | ||
{ | ||
"handler": "subroute", | ||
"routes": [ | ||
{ | ||
"handle": [ | ||
{ | ||
"body": "404 or 410 error from second site", | ||
"handler": "static_response" | ||
} | ||
], | ||
"match": [ | ||
{ | ||
"expression": "{http.error.status_code} in [410]" | ||
} | ||
] | ||
}, | ||
{ | ||
"handle": [ | ||
{ | ||
"body": "Error In range [500 .. 599] from second site", | ||
"handler": "static_response" | ||
} | ||
], | ||
"match": [ | ||
{ | ||
"expression": "{http.error.status_code} \u003e= 500 \u0026\u0026 {http.error.status_code} \u003c= 599" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"terminal": true | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.