The expected error for DNS lookup errors in lookup_srv should be the same as dial.
{
"admin": {
"disabled": true
},
"apps": {
"http": {
"servers": {
"srv0": {
"errors": {
"routes": [
{
"handle": [
{
"handler": "rewrite",
"uri": "/502.html"
},
{
"handler": "file_server",
"hide": [
"caddy.json"
]
}
],
"match": [
{
"expression": "{http.error.status_code} == 502"
}
],
"terminal": true
}
]
},
"listen": [
":443"
],
"routes": [
{
"handle": [
{
"handler": "reverse_proxy",
"upstreams": [
{
"lookup_srv": "wguoihebfoindfoibnwpoefjoienbfgiberish.com"
}
]
}
],
"match": [
{
"host": [
"localhost"
]
}
],
"terminal": true
}
]
}
}
}
}
}
This config will fail to render the 502 error page because Caddy is returning a 500 due to the no such host error from the DNS lookup failure.
However, if you change "lookup_srv": "wguoihebfoindfoibnwpoefjoienbfgiberish.com" to "dial": "wguoihebfoindfoibnwpoefjoienbfgiberish.com:80" Caddy will render the 502 error page as expected.
Both failures should result in a 502
Ok, looks like i fixed it locally. I'll check if everything else if fine and then make a PR.
It renders 502 error page both for lookup_srv and dial config entry, however i build from #3756 to actually check lookup_srv since it's not working on master.
I think that's a simple and effective fix! Thanks for that @aleert
Most helpful comment
Ok, looks like i fixed it locally. I'll check if everything else if fine and then make a PR.