You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Varnish配置中绕过robots.txt与sitemap.xml?

关于Varnish同时绕过sitemap.xml和robots.txt的语法验证

你给出的这段VCL语法完全可以同时实现sitemap.xml和robots.txt的绕过,逻辑通顺有效。配置生效后,当请求这两个文件时,Varnish会直接跳过缓存层,将请求转发至后端服务器,就能解决Google访问时出现的503 Service Unavailable问题。

不过可以把正则表达式优化得更严谨,合并成单条规则,避免匹配到无关路径(比如/sitemap.xml.bak或/subdir/robots.txt这类不需要绕过的请求):

# Bypass sitemap and robots.txt
if (req.url ~ "^/(sitemap\.xml|robots\.txt)$") {
    return (pass);
}

内容的提问来源于stack exchange,提问作者user86226

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 14:15:28