1

In the JS WebSocket library, you can limit the maximum allowed incoming message size via the maxPayload option.

I'd like to impose this limit in my Nginx reverse proxy layer, before it gets to my application server.

Does Nginx have a similar concept? Does client_max_body_size (doc) apply to incoming websocket messages?

rynop
  • 219
  • 4
  • 15

2 Answers2

1

When nginx sees the 101 Switching Protocols response from the backend, it begins to treat the connection as an opaque tunnel and passes traffic back and forth without any further inspection. There is no directive that will limit any particular Websocket message in any way.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
-1

According to this Mattermost NGINX conf it should be possible: https://docs.mattermost.com/install/config-proxy-nginx.html

Both a websocket connection (article) and your specified client_max_body_size (doc) are used therein, so I assume it has been tested and works if they mention it in their config.