mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-29 20:24:11 +08:00
138 lines
2.3 KiB
Plaintext
138 lines
2.3 KiB
Plaintext
example.com {
|
|
root * /srv
|
|
|
|
# Trigger errors for certain paths
|
|
error /private* "Unauthorized" 403
|
|
error /hidden* "Not found" 404
|
|
|
|
# Handle the error by serving an HTML page
|
|
handle_errors {
|
|
rewrite * /{http.error.status_code}.html
|
|
file_server
|
|
}
|
|
|
|
file_server
|
|
}
|
|
----------
|
|
{
|
|
"apps": {
|
|
"http": {
|
|
"servers": {
|
|
"srv0": {
|
|
"listen": [
|
|
":443"
|
|
],
|
|
"routes": [
|
|
{
|
|
"match": [
|
|
{
|
|
"host": [
|
|
"example.com"
|
|
]
|
|
}
|
|
],
|
|
"handle": [
|
|
{
|
|
"handler": "subroute",
|
|
"routes": [
|
|
{
|
|
"handle": [
|
|
{
|
|
"handler": "vars",
|
|
"root": "/srv"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"handle": [
|
|
{
|
|
"error": "Unauthorized",
|
|
"handler": "error",
|
|
"status_code": 403
|
|
}
|
|
],
|
|
"match": [
|
|
{
|
|
"path": [
|
|
"/private*"
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"handle": [
|
|
{
|
|
"error": "Not found",
|
|
"handler": "error",
|
|
"status_code": 404
|
|
}
|
|
],
|
|
"match": [
|
|
{
|
|
"path": [
|
|
"/hidden*"
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"handle": [
|
|
{
|
|
"handler": "file_server",
|
|
"hide": [
|
|
"./Caddyfile"
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"terminal": true
|
|
}
|
|
],
|
|
"errors": {
|
|
"routes": [
|
|
{
|
|
"match": [
|
|
{
|
|
"host": [
|
|
"example.com"
|
|
]
|
|
}
|
|
],
|
|
"handle": [
|
|
{
|
|
"handler": "subroute",
|
|
"routes": [
|
|
{
|
|
"group": "group0",
|
|
"handle": [
|
|
{
|
|
"handler": "rewrite",
|
|
"uri": "/{http.error.status_code}.html"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"handle": [
|
|
{
|
|
"handler": "file_server",
|
|
"hide": [
|
|
"./Caddyfile"
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"terminal": true
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |