Apache websockets with proxy_wstunnel and mosquitto

Page content

Spend last weekend trying to make apache with proxy_wstunnel to work.
The solution recommended is to add this in the apache config:

ProxyRequests off
ProxyPass /mqtt ws://
ProxyPassReverse /mqtt ws://

But no matter what it is a no go. So, where is the problem?

It’s the libwebsockets it doesn’t understand custom http headers X-… but apache adds some.

To add support for them in the file lextable-strings.h append before the blank string :


Then do compile and install:

gcc minilex.c -o minilex && ./minilex > lextable.h
gcc minilex.c -o minilex && ./minilex > lextable.h
make && make install

Yes, do it twice. You must have a working apache2 with proxy_wstunnel module talking to mosquitto broker.

Now let’s get on the mqtt stuff.

P.S. The proper fix is to ignore all custom headers as per the HTTP specification and not consider them dangerous.