Haproxy – 在Heroku上使用monitor-uri

我们在heroku上使用haproxy来在我们所有的各种微服务(也在heroku上)之间进行路由,所以我们只需要configuration中的一个url。

我试图用这个技巧:

http://discourse.haproxy.org/t/how-do-i-serve-a-single-static-file-from-haproxy/32

提供一个robots.txt来禁止拖拉我们的API(所有auth保护,这是为了性能,而不是安全原因)的一切。

这似乎是这样做的最轻量级的方式,并且它在本地运行得非常好(通过“heroku local”启动)。 但是,在我们实际的heroku环境中使用/robots.txt会导致503服务器响应中断。

haproxy.cfg snippet:

frontend http-in bind *:"${PORT}" monitor-uri /robots.txt errorfile 200 "${STATIC_PATH}/robots.http" errorfile 503 "${STATIC_PATH}/robots.http" 

其中STATIC_PATH在heroku中定义为“/ app / static”。

静态/ robots.http:

 HTTP/1.0 200 Found Cache-Control: no-cache Connection: close Content-Type: text/plain User-Agent: * Disallow: / 

我知道haproxy正在查找robots.http,因为如果我将env var设置为无效path,haproxy拒绝启动。 从文档中,它应该在内存中保存这个响应,并在monitor-uri匹配时提供服务。

如果删除“errorfile 200”这一行,haproxy将返回其默认服务器OK页面,所以monitor-uri正确匹配,200是它试图返回的响应。

“错误文件503”条目是因为这个: http : //comments.gmane.org/gmane.comp.web.haproxy/19803,但没有什么区别。

还有其他build议吗? 其他人之前尝试过吗?

谢谢,B