Reverse proxies
Put Murmur behind nginx, Caddy, HAProxy, or Traefik with tested recipes for HTTPS, HTTP/2 and HTTP/3 that keep SSE streams unbuffered and long-lived.
On this page
Terminate HTTPS at the proxy and use HTTP/1.1 from the proxy to Murmur. Murmur sends Connection: close on its streams. HTTP/2 and HTTP/3 multiplex requests that share a browser connection, including streams opened by different tabs. Keep enough concurrent stream slots for control requests as well as SSE. If clients reach the negotiated limit, use tab sharing or raise the proxy limit where supported, after sizing the proxy and Murmur for the extra streams. Each stream still uses an upstream socket.
Common settings
Set MURMUR_PUBLIC_URL to the public HTTPS base URL. Replace sse.example.com, certificate paths, and murmur:8080 with your own values. Bind Murmur to an interface reachable by the proxy on a private network. With the HTTP driver, set MURMUR_PUBLISH_URL to the internal server address.
| Public path | Methods Murmur accepts |
|---|---|
/sse |
GET, POST, OPTIONS |
/sse/subscriptions |
POST, OPTIONS when live changes are enabled |
/sse/whisper |
POST, OPTIONS when client events are enabled |
The recipes match exact paths and let Murmur dispatch methods. Keep /publish, /health, and /ready on the private network. Remove the whisper path if you do not use client events. In HTTP/1.1 and HTTP/2 tests, /publish/../sse, /sse/..%2Fpublish, and //publish did not reach the private publish endpoint through any of the four proxies.
The proxies forward Authorization, Last-Event-ID, Origin, and Content-Type with their normal request headers. Leave CORS and preflight to Murmur. Set allowed origins for cross-origin browsers. Adding another Access-Control-Allow-Origin can cause browsers to reject the response even when both values match. For credentialed cross-origin requests or extra request headers, configure CORS at the proxy for all three routes.
Murmur limits JSON subscription and live change bodies to 32,768 bytes by default. Whisper bodies have a separate 4,096-byte default. Keep any proxy request body limit at least as large as the larger configured value. The Nginx recipe allows 1 MiB. The other recipes leave body size enforcement to Murmur.
Disable response buffering and leave compression off for text/event-stream. The recipes delivered small events promptly even when the client requested gzip. If your proxy compresses other responses, exclude Murmur's SSE routes or media type. Use stream compression only if the encoder flushes after each event and small events still arrive promptly in a client test. The main configurations leave compression off. The Nginx section includes a tested gzip option.
Murmur sends a heartbeat every 20 seconds by default. Quiet HTTP/1.1 streams received four heartbeats over 82 seconds through each proxy. Set each response inactivity limit along the route comfortably above MURMUR_HEARTBEAT to allow for scheduling and network delays. If you increase the heartbeat interval, raise those limits too. A time limit on the entire response still expires even when heartbeats arrive.
Logging and client IPs
GET subscription URLs can carry token and connection in the query string. Keep query strings, request bodies, and Authorization out of proxy logs and traces. Keep X-Socket-ID out of Laravel request logs. Apply the same rules at any outer load balancer or CDN.
Nginx and HAProxy set X-Forwarded-For, X-Forwarded-Proto, and X-Forwarded-Host at the public listener. Caddy and Traefik set them automatically. Configure trusted sources at the proxy if it sits behind another load balancer. Murmur uses the transport peer address for its socket handling and has no trusted-proxy or PROXY protocol setting. Apply client-IP access rules at the proxy.
Connection capacity
A pool with MURMUR_MAX_CONNECTIONS=900, two nodes, and two workers per node can hold 3,600 streams. Budget one upstream socket per stream plus the client sockets. With HTTP/1.1, that is up to 7,200 proxy sockets. With HTTP/2, several streams can share each client socket. Leave additional capacity for idle client connections, control requests, health checks, listeners, and reloads.
Several Murmur nodes
Add each node to the same upstream pool for all three public paths. Use the Redis driver, the same event log and relay prefix, and the same MURMUR_SECRET on the nodes. Sticky sessions are optional. The Redis subscription relay routes changes and whisper requests to the node that owns the stream. That node authorizes whispers and uses Redis Pub/Sub to fan them out to other nodes. The shared event log allows a reconnect on another healthy node to replay retained events. With the HTTP driver, streams, control credentials, and replay history are local to one server. Affinity alone cannot share that history or distribute publishes.
Use the private /ready probe when choosing nodes for new requests. During shutdown, Murmur sends retry hints before ending its streams. The client reconnects using its last cursor. Whispers have no replay.
Nginx
Tested with Nginx 1.30.7 (nginx:1.30.7-alpine). Use this as nginx.conf. Nginx defaults to 128 concurrent HTTP/2 streams per connection. Set http2_max_concurrent_streams on this server if measurements show you need more.
Nginx's default is 512 connections per worker. This configuration allows 8,192 per worker, including upstream sockets. The recipe held 900 simultaneous SSE streams across nine HTTP/2 client connections in the test. Even one worker can handle the 7,200 sockets in the pool example with room for other traffic. Increase worker_connections and worker_rlimit_nofile as the pool grows, and give the Nginx service or container a hard open-file limit at least as high as worker_rlimit_nofile.
The 75-second proxy_read_timeout applies between upstream reads. The default is 60 seconds. Buffering is disabled explicitly, and Murmur also sends X-Accel-Buffering: no. Open TCP and UDP port 443. The stock image was tested with HTTP/3. If Nginx was built without the HTTP/3 module, remove the QUIC listener and the Alt-Svc header.
worker_processes auto;
worker_rlimit_nofile 16384;
events {
worker_connections 8192;
}
worker_shutdown_timeout 5s;
http {
upstream murmur_nodes {
least_conn;
server murmur:8080;
}
server {
listen 443 ssl;
listen 443 quic reuseport;
http2 on;
ssl_certificate /etc/ssl/certs/murmur.pem;
ssl_certificate_key /etc/ssl/private/murmur.key;
ssl_protocols TLSv1.2 TLSv1.3;
add_header Alt-Svc 'h3=":443"; ma=86400' always;
access_log off;
error_log /dev/stderr crit;
client_max_body_size 1m;
location ~ ^/sse(?:/subscriptions|/whisper)?$ {
proxy_pass http://murmur_nodes;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_buffering off;
proxy_read_timeout 75s;
gzip off;
}
location / {
return 404;
}
}
}If you need gzip for SSE, replace gzip off; in the location with these directives. Keep proxy_buffering off; so upstream writes flush through the gzip filter. A small compressed event arrived promptly in the HTTP/2 test.
gzip on;
gzip_types text/event-stream;
gzip_min_length 1;Add a server line inside murmur_nodes for each additional node. Use an external readiness check to remove draining nodes from the pool.
Run nginx -t before nginx -s reload. Old workers drain existing streams for up to the configured worker_shutdown_timeout, then close them.
Credentialed CORS and extra headers
Use this option when a cross-origin client sends cookies or uses headers outside Murmur's default list. The proxy answers preflight and owns the CORS response headers on these routes. Keep the same explicit origin allowlist in MURMUR_ALLOWED_ORIGINS so Murmur accepts the forwarded POST and GET requests. Replace the example origin and allow only the additional headers the application needs. Credentialed requests require a specific allowed origin.
Add these maps inside http, outside server.
map $http_origin $murmur_cors_origin {
default "";
"https://app.example.test" "https://app.example.test";
}
map $murmur_cors_origin $murmur_cors_credentials {
default "true";
"" "";
}Add the following inside the SSE location. The proxy hides Murmur's CORS headers and supplies one consistent set for preflight and actual responses. Requests from an origin outside the map receive no Access-Control-Allow-Origin, so the browser denies access.
proxy_hide_header Access-Control-Allow-Origin;
proxy_hide_header Access-Control-Allow-Credentials;
proxy_hide_header Access-Control-Allow-Methods;
proxy_hide_header Access-Control-Allow-Headers;
proxy_hide_header Access-Control-Expose-Headers;
proxy_hide_header Access-Control-Max-Age;
add_header_inherit merge;
add_header Access-Control-Allow-Origin $murmur_cors_origin always;
add_header Access-Control-Allow-Credentials $murmur_cors_credentials always;
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS" always;
add_header Access-Control-Allow-Headers "Authorization, Content-Type, Last-Event-ID, X-Request-ID" always;
add_header Access-Control-Expose-Headers "Retry-After, X-Murmur-Protocol" always;
add_header Access-Control-Max-Age 600 always;
add_header Vary Origin always;
if ($request_method = OPTIONS) {
return 204;
}Caddy
Tested with Caddy 2.11.9 (caddy:2-alpine). Point DNS at Caddy, allow TCP ports 80 and 443 and UDP port 443, and persist Caddy's data directory for automatic HTTPS. HTTP/2 and HTTP/3 are enabled by default. The test changed only the site address to https://localhost and added a tls line for a local certificate. It exercised HTTP/2 and HTTP/3. Automatic HTTPS with public ACME issuance was untested. Caddy advertises 250 concurrent HTTP/2 streams per connection in this build. Use tab sharing if you reach that limit.
The tested container inherited a soft and hard open-file limit of 1,048,576. The ceiling depends on the runtime. Raise LimitNOFILE in systemd or the container runtime’s nofile limits if your socket budget requires it.
Caddy flushes text/event-stream immediately. The 75-second response_header_timeout only limits the wait for upstream headers. There is no upstream response-body read timeout by default. Leave stream lifetime and server write deadlines unset for long-lived SSE. If you configure an inactivity deadline, keep it above the heartbeat.
{
grace_period 5s
}
sse.example.com {
@murmur path /sse /sse/subscriptions /sse/whisper
handle @murmur {
reverse_proxy murmur:8080 {
transport http {
versions 1.1
response_header_timeout 75s
}
}
}
handle {
respond 404
}
}List extra nodes on the reverse_proxy line. Add lb_policy least_conn and health_uri /ready inside the block for an active least-connections pool. Use caddy reload --config /etc/caddy/Caddyfile to apply changes. On reload, the five-second grace period bounds the wait for the old HTTP server to drain. In the test, an existing HTTP/2 SSE stream stayed on the old configuration and was still open seven seconds after reload. On SIGTERM, Caddy waited about five seconds and then exited, closing the active stream. Allow the process at least that long before forcing it to exit.
HAProxy
Tested with HAProxy 3.2.27 (haproxy:3.2-alpine). Concatenate the certificate chain and private key into the PEM file named in bind. This listener offers HTTP/2 over TLS with a default of 100 concurrent streams per connection. If needed, set tune.h2.fe.max-concurrent-streams under global.
HAProxy computes its global maxconn from the process resource limits when unset. It was 524,249 with an open-file limit of 1,048,576 in the test container. A frontend inherits the global limit by default. A server has no separate limit unless you set maxconn on its server line. Set the global and frontend limits for client connections and size server limits for each node’s upstream capacity. HAProxy configuration manual
The 75-second client and server timeouts are inactivity limits. HAProxy forwards streamed responses without waiting for the full body. Leave compression directives out of this frontend and backend.
global
hard-stop-after 5s
defaults
mode http
timeout connect 5s
timeout client 75s
timeout server 75s
frontend public
bind :443 ssl crt /etc/haproxy/tls.pem alpn h2,http/1.1
acl stream_path path /sse /sse/subscriptions /sse/whisper
http-request deny deny_status 404 unless stream_path
http-request set-header X-Forwarded-For %[src]
http-request set-header X-Forwarded-Proto https
http-request set-header X-Forwarded-Host %[req.hdr(Host)]
default_backend murmur_nodes
backend murmur_nodes
balance leastconn
option httpchk GET /ready
server murmur murmur:8080 check proto h1Add a named server line with check proto h1 for each node. The readiness check runs on the private backend. Run HAProxy in master-worker mode (haproxy -W -db -f /etc/haproxy/haproxy.cfg in a container). Validate with haproxy -c -f /etc/haproxy/haproxy.cfg, then send SIGUSR2 to the master to reload. The old worker has up to hard-stop-after to drain before closing remaining streams.
Traefik
Tested with Traefik 3.6.25 (traefik:v3.6). Start Traefik with --configFile=/etc/traefik/traefik.yaml. HTTP/2 defaults to 250 concurrent streams per connection. Set entryPoints.websecure.http2.maxConcurrentStreams if needed.
The tested container inherited a soft and hard open-file limit of 1,048,576. The ceiling depends on the runtime. Raise LimitNOFILE in systemd or the container runtime’s nofile limits if your socket budget requires it.
Keep writeTimeout at zero. It would otherwise cap the entire response. The default 180-second keep-alive idle timeout applies to idle connections between requests. Leave the buffer and compress middlewares off the router. Traefik flushes recognized streaming responses immediately. A negative flushInterval also requests an immediate flush after each write for other responses.
Save the static configuration as /etc/traefik/traefik.yaml.
entryPoints:
websecure:
address: ":443"
transport:
respondingTimeouts:
writeTimeout: 0s
lifeCycle:
graceTimeOut: 5s
providers:
file:
directory: /etc/traefik/dynamicSave the dynamic configuration as /etc/traefik/dynamic/murmur.yaml. Add a URL under servers for each additional node.
tls:
certificates:
- certFile: /etc/ssl/certs/murmur.pem
keyFile: /etc/ssl/private/murmur.key
http:
routers:
murmur:
entryPoints: [websecure]
rule: Path(`/sse`) || Path(`/sse/subscriptions`) || Path(`/sse/whisper`)
service: murmur
tls: {}
services:
murmur:
loadBalancer:
responseForwarding:
flushInterval: -1ms
healthCheck:
path: /ready
servers:
- url: http://murmur:8080Mount the dynamic configuration directory so the file provider can detect changes. Existing SSE streams stayed open when the file provider applied a service change. Static configuration changes require a restart. Allow at least graceTimeOut before your supervisor force-kills the process.
Reconnects after a proxy change
Restarting a proxy can end active streams. Give clients time to reconnect and keep enough event history for them to catch up. The Murmur client sends its replay cursor when reconnecting. To verify replay with curl, save the last id: from the stream, disconnect, publish another event, and reconnect with Last-Event-ID set to the saved ID. Include the same topics and valid credentials.
Managed load balancers and CDNs
We did not test these services. Keep the public path allowlist at your origin proxy. Confirm that the complete path to the browser delivers each event and heartbeat promptly.
| Service | Timeouts and buffering |
|---|---|
| AWS Application Load Balancer | The default connection idle timeout is 60 seconds. Idle timeout Set it above the heartbeat. Application bytes reset it, while HTTP/2 PING frames do not. The ALB attributes documentation gives no per-event flush guarantee. |
| Amazon CloudFront | The origin response timeout defaults to 30 seconds and applies before the first origin response and between response packets. Origin response timeout Leave response completion timeout unset to avoid a separate total-response limit. Enable methods that include POST and OPTIONS, use CachingDisabled with an AllViewer origin request policy, and disable automatic compression for these paths. A disabled cache does not establish a per-event flush guarantee. Origin settings, custom-origin behavior, managed cache policies, managed origin request policies |
| Cloudflare | The default origin Proxy Read Timeout is 125 seconds for error 524. Cloudflare 524 reference Bypass cache on the Murmur paths. Cloudflare documents immediate forwarding by default and an Enterprise Response Buffering option that waits for the whole response. Leave that option off. Connection limits, cache changes, configuration settings |
| Google Cloud external Application Load Balancer | The backend service timeout defaults to 30 seconds and covers the entire SSE response, including continuously active streams. Request distribution and timeouts Raise it to suit the desired stream lifetime and expect reconnects. The vendor documents returning headers and any body received before timeout, without a per-event flush guarantee. |