Apache websockets with proxy_wstunnel and mosquitto
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://127.0.0.1:8082
ProxyPassReverse /mqtt ws://127.0.0.1:8082
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 :
“x-forwarded-server”,
“x-forwarded-for”,
“x-forwarded-host”,
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.