Server-Sent Events buffering with reverse_proxy

1. Caddy version (caddy version):


2. How I run Caddy:

as a docker container, to reverse proxy to a golang app running in another container in the same network.

a. System environment:

Docker For Desktop on Windows 10 (WSL2)

b. Command:

c. Service/unit/compose file:

    image: caddy:2.3.0-alpine
      - ./scripts/Caddyfile:/etc/caddy/Caddyfile
      - 8787:80

d. My complete Caddyfile or JSON config:

  route /api/* {
      reverse_proxy server:8000
  route /* {
    root * /srv
    try_files {path} /index.html

3. The problem I’m having:

As mentioned in the streaming section, reverse_proxy (Caddyfile directive) — Caddy Documentation, caddy checks the mime type to be text/event-stream and instantly flushes the response. I confirmed this in the reverse proxy code too, however its not doing so for my application for some reason

In the apps frontend I can see the events coming all at once and after the server closes the stream i.e caddy is buffering it.

4. Error messages and/or full log output:

5. What I already tried:

explicitly setting flush_interval -1 in the Caddyfile

6. Links to relevant resources:

Does this happen without Docker too? Can we reproduce it more simply?

My bad, it was an issue with the frontend’s react dev server using its own proxy handling the event stream incorrectly and not caddy.


This topic was automatically closed after 30 days. New replies are no longer allowed.