html - 服务器通过 varnish 代理发送事件

标签 html varnish server-sent-events

我有一个在 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/

相关文章:

html - 居中对齐 Bootstrap 导航按钮

html - flexbox 1 div 中的 2 个元素堆叠

android - 在 Android 中获取 503 作为 Http 响应?

websocket - 我可以在 HTML Web 应用程序中使用哪种服务器推送技术?

java - SseEmitter 和 jackson 没有适合类 java.lang.String 的转换器

ruby-on-rails - 使用 sse 在 ruby​​ on rails 4 中进行异步响应

html - Bootstrap 3 : Vertically stack buttons after first one wraps?

jquery - IOS html css Z-Index 和位置绝对不适用于重叠的 DIV

cloud - 在 Varnish 反向代理中使用具有多个 IP 的域名

Magento 2 + WHM + SSL + Varnish 配置问题