我有一个在 Varnish 代理后面运行的网站。任何为服务器发送事件而打开的连接都不会获取任何内容,也不会关闭。 Varnish 似乎会等待内容流结束,然后再将该内容转发到浏览器。并且它会保持与服务器的连接打开,直到内容结束。这两个问题都与服务器发送的事件不兼容。
如何配置 Varnish 以立即将内容刷新到浏览器并在浏览器关闭连接时关闭与服务器的连接?
或者我可以动态地指示 Varnish 完全充当连接的传递,就好像它根本不存在一样?我可以在非代理系统上运行完全相同的 Web 应用程序,没有任何问题。而且我无法在此设置中完全绕过 Varnish(例如不同的端口)。
最佳答案
您是否尝试过在vcl_recv中返回管道?
来自 documentation :
Pipe can be returned from vcl_recv as well. Pipe short circuits the client and the backend connections and Varnish will just sit there and shuffle bytes back and forth. Varnish will not look at the data being send back and forth - so your logs will be incomplete. Beware that with HTTP 1.1 a client can send several requests on the same connection and so you should instruct Varnish to add a "Connection: close" header before actually returning pipe.
不要忘记,您必须仅为 SSE 传入请求返回 pipe。
关于html - 服务器通过 varnish 代理发送事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12308923/