Nginx reverse proxy and mosquitto docker containers


Is it possible to use jwilder/nginx-proxy to route mqtt messages to eclipse-mosquitto containers?

So the clients can reach different brokers under different subdomains but under same port: on port 1883 on port 1883



As Brits says in the comments, you can not do hostname based proxying with native MQTT. Hostname based proxying only works with HTTP because the protocol explicitly includes the hostname in each request (the Host HTTP header), MQTT does not contain any information to identify the hostname the client is trying to connect to in the protocol.

It is possible to do it if using MQTT over TLS as the hostname is included in the TLS handshake so the server knows which certificate to present to the client. Detail of how to setup Nginx to use the TLS SNI header to proxy MQTT to different backends can be found on my blog here and with Traefik here.

Both of those guides are for how to edit the settings file directly, not how to use it with the jwilder/nginx-proxy. It’s been a while since I used that proxy config, but I don’t think it supports automatically setting up TCP stream proxying as opposed to HTTP proxying.

Answered By – hardillb

Answer Checked By – David Marino (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.