1. Caddy version (caddy version
):
2.4.0
2. How I run Caddy:
a. System environment:
Reproduced on both Windows 10 and Amazon Linux 2.
b. Command:
For windows
caddy_win.exe run --resume
For Linux
sudo systemctl start caddy
c. Service/unit/compose file:
d. My complete Caddyfile or JSON config:
Just going to show the windows configuration from here on out.
{
"admin": {
"listen": ":2020"
},
"apps": {
"http": {
"servers": {
"server443": {
"@id": "routes - global",
"listen": [
":443"
],
"routes": [
{
"handle": [
{
"@id": "routes - dev.uafricastore.local",
"handler": "subroute",
"routes": []
},
{
"handler": "reverse_proxy",
"headers": {
"request": {
"set": {
"From": [
"localhost"
],
"Host": [
"{http.request.host}"
],
"X-Forwarded-Proto": [
"https"
]
}
}
},
"upstreams": [
{
"dial": "localhost:10047"
}
]
}
],
"match": [
{
"host": [
"*.dev.uafricastore.local"
]
}
]
},
{
"@id": "dev.uafricastore.local",
"handle": [
{
"handler": "reverse_proxy",
"headers": {
"request": {
"set": {
"From": [
"localhost"
],
"Host": [
"{http.request.host}"
],
"X-Forwarded-Proto": [
"https"
]
}
}
},
"upstreams": [
{
"dial": "localhost:10047"
}
]
}
],
"match": [
{
"host": [
"dev.uafricastore.local"
]
}
]
},
{
"handle": [
{
"@id": "routes - uafricastore.local",
"handler": "subroute",
"routes": [
{
"@id": "42 - custom-redirect",
"handle": [
{
"handler": "static_response",
"headers": {
"Location": [
"https://testcustagain1.local"
]
},
"status_code": 301
}
],
"match": [
{
"host": [
"testcustagain1.uafricastore.local"
]
}
]
},
{
"@id": "53 - custom-redirect",
"handle": [
{
"handler": "static_response",
"headers": {
"Location": [
"https://testchange2.local"
]
},
"status_code": 301
}
],
"match": [
{
"host": [
"testchange2.uafricastore.local"
]
}
]
}
]
},
{
"handler": "reverse_proxy",
"headers": {
"request": {
"set": {
"From": [
"localhost"
],
"Host": [
"{http.request.host}"
],
"X-Forwarded-Proto": [
"https"
]
}
}
},
"upstreams": [
{
"dial": "localhost:10041"
}
]
}
],
"match": [
{
"host": [
"*.uafricastore.local"
]
}
]
},
{
"@id": "uafricastore.local",
"handle": [
{
"handler": "reverse_proxy",
"headers": {
"request": {
"set": {
"From": [
"localhost"
],
"Host": [
"{http.request.host}"
],
"X-Forwarded-Proto": [
"https"
]
}
}
},
"upstreams": [
{
"dial": "localhost:10041"
}
]
}
],
"match": [
{
"host": [
"uafricastore.local"
]
}
]
},
{
"@id": "19 - custom",
"handle": [
{
"handler": "reverse_proxy",
"headers": {
"request": {
"set": {
"Host": [
"{http.request.host}"
],
"X-Forwarded-Proto": [
"https"
]
}
}
},
"upstreams": [
{
"dial": "127.0.0.1:10041"
}
]
}
],
"match": [
{
"host": [
"custom4store.local",
"www.custom4store.local"
]
}
]
},
{
"@id": "27 - redirect",
"handle": [
{
"handler": "static_response",
"headers": {
"Location": [
"https://test9.uafricastore.local"
]
},
"status_code": 301
}
],
"match": [
{
"host": [
"www.test9.local"
]
}
]
},
{
"@id": "42 - custom",
"handle": [
{
"handler": "reverse_proxy",
"headers": {
"request": {
"set": {
"Host": [
"{http.request.host}"
],
"X-Forwarded-Proto": [
"https"
]
}
}
},
"upstreams": [
{
"dial": "127.0.0.1:10041"
}
]
}
],
"match": [
{
"host": [
"testcustagain1.local"
]
}
]
},
{
"@id": "53 - custom",
"handle": [
{
"handler": "reverse_proxy",
"headers": {
"request": {
"set": {
"Host": [
"{http.request.host}"
],
"X-Forwarded-Proto": [
"https"
]
}
}
},
"upstreams": [
{
"dial": "127.0.0.1:10041"
}
]
}
],
"match": [
{
"host": [
"testchange2.local"
]
}
]
}
]
}
}
}
},
"logging": {
"logs": {
"": {
"level": "debug"
}
}
}
}
3. The problem Iām having:
I can not use the @id
selector to select the correct āsectionā. It returns a 200 status code but with no content.
This used to work on the previous version: v2.3.0 but stopped after upgrading v.2.4.0
I have tried on both Windows 10 and Ubuntu (running on AWS, AMI: ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20201026)
4. Error messages and/or full log output:
curl --location --request GET 'http://localhost:2020/id/routes - global/routes/' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json'
GET /id/routes%20-%20global/routes/ HTTP/1.1
Content-Type: application/json
Accept: application/json
User-Agent: PostmanRuntime/7.28.0
Cache-Control: no-cache
Postman-Token: d1d9532c-cf3b-45d9-8632-fd2ff13238d2
Host: localhost:2020
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
HTTP/1.1 200 OK
Date: Wed, 19 May 2021 12:55:06 GMT
Content-Length: 0
5. What I already tried:
- Escaping the spaces
- Removing the
-
between the words - Replacing
-
with an underscore - Adding and removing the Accept and Content-Type headers
- Different operating systems
- Selecting using ādirect ancestorsā aka
http://127.0.0.1:2020/config/apps/http/servers/server443/routes
works