Reputation: 85
I am running a MQTT Mosquitto server listening on port 8883 using TLS in a docker container with name 'mosquitto'.
In another docker container in the same network I am running an Apache webserver with a webpage at my_domain (at port 443).
The Apache should forward all requests to my_domain/mosquitto
to the Mosquitto broker.
using my_domain/mosquitto. Thus I add
ProxyPreserveHost On
ProxyPass /mosquitto ws://mosquitto:8883
ProxyPassReverse /mosquitto ws://mosquitto:8883
to my httpd.conf
which redirects https-browser-calls to my_domain/mosquitto
to mosquitto.
This of course result in an OpenSSL error at Mosquitto.
But using the MQTT client (python) results in Name or service not known
What I am doing wrong?
P.S.: The SSL keys / certificates for the Apache and the Mosquitto are different. When disabling the webserver, redirect the Mosquitto to port 443 via docker the connection is working.
Upvotes: 0
Views: 1744
Reputation: 59618
To use a HTTP reverse proxy (Apache) to proxy for a MQTT broker you must use MQTT of Websockets (because WebSocket connections are bootstrapped over HTTP).
A native MQTT connection will just not work as Apache has no way of understanding the native protocol format.
You will need to enable a Websocket Listener in Mosquitto and tell the client to make a websocket connect.
You should also probably be using /mqtt
not /mosquitto
as the path to proxy as this is the default for WebSocket connects
Upvotes: 1