关于caddy设置反向代理后,访问提示域名未备案的问题
问题背景
有两台服务器,A-阿里云,B-腾讯云, B服务器部署了caddy,网页部署在A服务器上。
现在要求访问通过B对A进行反向代理(即B->A), B服务器上的caddy配置如下
{
}
:443 {
encode zstd gzip
tls cert/a.pem cert/a.key
file_server {
index index.html
root html
}
reverse_proxy /a/* http://A服务器的地址
}
当通过浏览器访问 http://B.com/a/index.html 时,阿里云会拦截并提示域名未备案。
解决办法
反向代理时更改一下host头
{
}
:443 {
encode zstd gzip
tls cert/a.pem cert/a.key
file_server {
index index.html
root html
}
handle_path /a/* {
reverse_proxy http://b服务器地址 {
header_up Host {upstream_hostport}
}
}
}