此线程中的想法对于我们这些使用 caddy 作为反向代理 的人来说也很棒,无论是作为独立应用程序还是使用 Cloudflare Tunnels。
discourse.example.org {
reverse_proxy <host | ip>:port
handle_errors 5xx {
root * /path/to/error-pages
rewrite * /error.html
file_server {
status 404
}
}
}
仅在使用 Cloudflare Tunnels 时 status 404 部分才重要。如果 caddy 向 Cloudflare 返回 5xx,Cloudflare Tunnel 将显示其自己的断开连接错误。更改状态表示 Cloudflare 存在一个有效的实时连接,该连接将提供错误页面。