wandenberg/nginx-push-stream-module

GZIP settings for websockets

Closed this issue · 2 comments

Hi Wandenberg,

Is there a way to set the push stream module to send out gzipped data through websockets?

Even when connecting with:
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
Accept-Encoding: gzip, deflate, br

the data comes out in plain text.

In the nginx.conf I've set:
gzip on;
gzip_types *;

When looking at the packets from tcdump, the JSON data being pushed through is in plain text.

Also, thanks for all your hard work on the push stream module. It's great!

Hi @Ninj0r,

The WebSocket protocol requires some changes on how the message is sent and parsed, for instance, it has a binary header to specify the message type and length. All this on top of the HTTP protocol. So the Nginx gzip filter would not know how to compress the message and still adding the right header to be a valid WebSocket frame.
So far I did not add the support to compress the message before pushing it in the module. And it is not on the roadmap.
One option, if you really need to use gzip with WebSocket, would be to you send the message already zipped to the module, it accepts binary messages.
The WebSocket implementation used in the pushstream module was done before Nginx add any kind of support to WebSocket, I did not check yet if the latest versions have any feature that I can use on this matter.

Hi @wandenberg,

Thanks for the quick response. I understand.