反向代理并修改网页内 cdn 链接 via Caddy

目的

反向代理某服务,并替换网页内 cdn 链接为其他可访问的 url

安装

安装 Caddy 时添加 http.filter 插件
相关文档

配置 Caddyfile

https://mysite.com {
    filter rule {
        content_type text/html.*
        search_pattern cdn.miansite.com
        replacement cdn.mysite.com
    }

    proxy / https://miansite.com {
        header_downstream -Content-Security-Policy
        header_downstream -Strict-Transport-Security
        header_downstream -Public-Key-Pins
        header_downstream -X-XSS-Protection
    }
    gzip
    tls [email protected]
}

https://cdn.mysite.com {
    proxy / cdn.miansite.com {
        header_downstream -Content-Security-Policy
        header_downstream -Strict-Transport-Security
        header_downstream -Public-Key-Pins
        header_downstream -X-XSS-Protection
    }
    gzip
    tls [email protected]
}


以上

Comments
Write a Comment