mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-16 21:56:40 -05:00
259 lines
No EOL
4.6 KiB
Text
259 lines
No EOL
4.6 KiB
Text
:80 {
|
|
@matcher {
|
|
method GET
|
|
}
|
|
respond @matcher "get"
|
|
|
|
@matcher2 method POST
|
|
respond @matcher2 "post"
|
|
|
|
@matcher3 not method PUT
|
|
respond @matcher3 "not put"
|
|
|
|
@matcher4 vars "{http.request.uri}" "/vars-matcher"
|
|
respond @matcher4 "from vars matcher"
|
|
|
|
@matcher5 vars_regexp static "{http.request.uri}" `\.([a-f0-9]{6})\.(css|js)$`
|
|
respond @matcher5 "from vars_regexp matcher with name"
|
|
|
|
@matcher6 vars_regexp "{http.request.uri}" `\.([a-f0-9]{6})\.(css|js)$`
|
|
respond @matcher6 "from vars_regexp matcher without name"
|
|
|
|
@matcher7 `path('/foo*') && method('GET')`
|
|
respond @matcher7 "inline expression matcher shortcut"
|
|
|
|
@matcher8 {
|
|
header Foo bar
|
|
header Foo foobar
|
|
header Bar foo
|
|
}
|
|
respond @matcher8 "header matcher merging values of the same field"
|
|
|
|
@matcher9 {
|
|
query foo=bar foo=baz bar=foo
|
|
query bar=baz
|
|
}
|
|
respond @matcher9 "query matcher merging pairs with the same keys"
|
|
|
|
@matcher10 {
|
|
header !Foo
|
|
header Bar foo
|
|
}
|
|
respond @matcher10 "header matcher with null field matcher"
|
|
|
|
@matcher11 remote_ip private_ranges
|
|
respond @matcher11 "remote_ip matcher with private ranges"
|
|
}
|
|
----------
|
|
{
|
|
"apps": {
|
|
"http": {
|
|
"servers": {
|
|
"srv0": {
|
|
"listen": [
|
|
":80"
|
|
],
|
|
"routes": [
|
|
{
|
|
"match": [
|
|
{
|
|
"method": [
|
|
"GET"
|
|
]
|
|
}
|
|
],
|
|
"handle": [
|
|
{
|
|
"body": "get",
|
|
"handler": "static_response"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"match": [
|
|
{
|
|
"method": [
|
|
"POST"
|
|
]
|
|
}
|
|
],
|
|
"handle": [
|
|
{
|
|
"body": "post",
|
|
"handler": "static_response"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"match": [
|
|
{
|
|
"not": [
|
|
{
|
|
"method": [
|
|
"PUT"
|
|
]
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"handle": [
|
|
{
|
|
"body": "not put",
|
|
"handler": "static_response"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"match": [
|
|
{
|
|
"vars": {
|
|
"{http.request.uri}": [
|
|
"/vars-matcher"
|
|
]
|
|
}
|
|
}
|
|
],
|
|
"handle": [
|
|
{
|
|
"body": "from vars matcher",
|
|
"handler": "static_response"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"match": [
|
|
{
|
|
"vars_regexp": {
|
|
"{http.request.uri}": {
|
|
"name": "static",
|
|
"pattern": "\\.([a-f0-9]{6})\\.(css|js)$"
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"handle": [
|
|
{
|
|
"body": "from vars_regexp matcher with name",
|
|
"handler": "static_response"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"match": [
|
|
{
|
|
"vars_regexp": {
|
|
"{http.request.uri}": {
|
|
"pattern": "\\.([a-f0-9]{6})\\.(css|js)$"
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"handle": [
|
|
{
|
|
"body": "from vars_regexp matcher without name",
|
|
"handler": "static_response"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"match": [
|
|
{
|
|
"expression": "path('/foo*') \u0026\u0026 method('GET')"
|
|
}
|
|
],
|
|
"handle": [
|
|
{
|
|
"body": "inline expression matcher shortcut",
|
|
"handler": "static_response"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"match": [
|
|
{
|
|
"header": {
|
|
"Bar": [
|
|
"foo"
|
|
],
|
|
"Foo": [
|
|
"bar",
|
|
"foobar"
|
|
]
|
|
}
|
|
}
|
|
],
|
|
"handle": [
|
|
{
|
|
"body": "header matcher merging values of the same field",
|
|
"handler": "static_response"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"match": [
|
|
{
|
|
"query": {
|
|
"bar": [
|
|
"foo",
|
|
"baz"
|
|
],
|
|
"foo": [
|
|
"bar",
|
|
"baz"
|
|
]
|
|
}
|
|
}
|
|
],
|
|
"handle": [
|
|
{
|
|
"body": "query matcher merging pairs with the same keys",
|
|
"handler": "static_response"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"match": [
|
|
{
|
|
"header": {
|
|
"Bar": [
|
|
"foo"
|
|
],
|
|
"Foo": null
|
|
}
|
|
}
|
|
],
|
|
"handle": [
|
|
{
|
|
"body": "header matcher with null field matcher",
|
|
"handler": "static_response"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"match": [
|
|
{
|
|
"remote_ip": {
|
|
"ranges": [
|
|
"192.168.0.0/16",
|
|
"172.16.0.0/12",
|
|
"10.0.0.0/8",
|
|
"127.0.0.1/8",
|
|
"fd00::/8",
|
|
"::1"
|
|
]
|
|
}
|
|
}
|
|
],
|
|
"handle": [
|
|
{
|
|
"body": "remote_ip matcher with private ranges",
|
|
"handler": "static_response"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |