Can Nginx limit incoming websocket message size?

rynop asked:

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?

My answer:


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.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.