example.com {
import log example.com
import common
handle /api/v2/* {
reverse_proxy http://127.0.0.1:10000
}
handle_path /api/* {
reverse_proxy http://127.0.0.1:8080 {
@errors status 404
handle_response @errors {
reverse_proxy http://127.0.0.1:10000 {
rewrite /api{uri}
}
}
}
}
handle /builder/* {
reverse_proxy http://127.0.0.1:10000
}
handle {
reverse_proxy http://127.0.0.1:10000 {
rewrite /prefix{uri}
}
}
}
如果去掉下面这段配置,/app/v2/* 路径的请求就会报 502 错误,不知道是为什么,有大佬懂吗
handle /api/v2/* {
reverse_proxy http://127.0.0.1:10000
}
虽然现在网站正常了,但是不知道原因好难受
8080 端口服务被请求未定义的路由一定返回 404
开 debug 模式看了一下错误信息
{
"level": "debug",
"ts": 1727663872.4190404,
"logger": "http.handlers.reverse_proxy",
"msg": "upstream roundtrip",
"upstream": "127.0.0.1:10000",
"duration": 0.000241584,
"request": {
"proto": "HTTP/2.0",
"method": "POST",
"host": "example.com",
"uri": "/api/v2/queries/query_datasource_d417999c7d824bb1bb53ba44c212df71_b8485022734c4405bcd476f6d67435a0",
"headers": {
"Sec-Ch-Ua": [
"\"Microsoft Edge\";v=\"129\", \"Not=A?Brand\";v=\"8\", \"Chromium\";v=\"129\""
],
"X-Forwarded-Proto": [
"https"
],
"Sec-Fetch-Mode": [
"cors"
],
"Sec-Fetch-Site": [
"same-origin"
],
"Accept-Encoding": [
"gzip, br"
],
"X-Budibase-Api-Version": [
"1"
],
"Priority": [
"u=1, i"
],
"Content-Length": [
"17"
],
"Accept": [
"application/json"
],
"Sec-Ch-Ua-Mobile": [
"?0"
],
"X-Forwarded-Host": [
"example.com"
],
"Cf-Ray": [
"8cb0d56288647c73-LAX"
],
"User-Agent": [
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0"
],
"Cookie": [
"REDACTED"
],
"Sec-Fetch-Dest": [
"empty"
],
"Cdn-Loop": [
"cloudflare; loops=1"
],
"X-Budibase-App-Id": [
"app_79a24f5a85c94e6c94c81448370a144a"
],
"Origin": [
"https://example.com"
],
"X-Budibase-Session-Id": [
"cf88312de49d446878b0f2f88f2664485"
],
"X-Budibase-Type": [
"client"
],
"Sec-Ch-Ua-Platform": [
"\"Windows\""
],
"Content-Type": [
"application/json"
]
},
"tls": {
"resumed": false,
"version": 772,
"cipher_suite": 4865,
"proto": "h2",
"server_name": "example.com"
}
},
"error": "net/http: HTTP/1.x transport connection broken: http: ContentLength=17 with Body length 0"
}
我在 Caddy 论坛发帖询问了 Issues with Reverse Proxy Configuration in Caddy Server - #6 by francislavoie - Help - Caddy Community
开发团队回复了一些内容