I am new to Mosquitto,
How do I access Mosquitto Broker that is running in Docker on a Synology NAS.
I need to find / enable external address of the Broker so my Particle Boron can communicate with the Broker.
Your help would be greatly appreciated.
Sorry for the delay replying!
There are two things you need to consider from the Mosquitto side when running on Docker. First off, you need to configure one or more ports that Mosquitto will listen on. You do this in your configuration file. Here are some examples, there are more details on the configuration file at mosquitto.conf man page | Eclipse Mosquitto and
# Listener with no encryption and no authentication/access control
# Listener with no encryption, with password and acl file access
# See https://mosquitto.org/man/mosquitto_passwd-1.html for info on password files
# Listener with no encryption, with dynamic security plugin
# Listener with encryption, with dynamic security plugin
# See https://mosquitto.org/documentation/dynamic-security/
Once you have your configuration file, it needs to be provided to your container. I would suggest using a local directory structure like this for your container data:
The second step is that you need to provide access to the port used in the container. If you’re running docker directly it would look like this, assuming you’re using one of the port 1883 options and following the above local directory structure:
docker run -it -v mosquitto/config:/mosquitto/config -v mosquitto/data:/mosquitto/data -p 1883:1883 eclipse-mosquitto:2
That gives you a running Mosquitto instance listening on port 1883/8883 of the NAS external interface. The next step is to find the external IP address of your NAS and connect to it - doing that is down to you.
I hope that helps.
Thank you so much for your help, you are a life saver, I greatly appreciate it.
@chela, Do you have a fixed IP for your NAS or do you need further help there?
Yes I have a fixed IP address for my NAS which is an internal address, I have an external address for my internet connection but I’m not sure what I use as an address when trying to access the NAS externally ie to access the Mosquitto broker which is running in Docker - where do I find the address that will get me through to the broker ?
I hope that makes sense.
in this case you have to set something in your router up that your internal device gets linked to an externally reachable IP and port. If your external IP is dynamic then you can look at https://www.noip.com/free, this is a free service to link a URL from them to your dynamic IP. I haven’t tried it out yet, but @Tizian recently forwarded me that interesting tutorial where somebody makes a raspberry pi externally available: HOW TO CONNECT A RASPBERRY PI WEB SERVER TO THE INTERNET: Host a website | Raspberry Pi Projects - YouTube
Again disclaimer: I did not try it yet and all stuff where you make an IP/port externally available you have to be careful that you do not create an IT sec vulnerability.
Good luck Let us know if you got it running finally and how you did it …
I will let you know how I go, I appreciate your help.
@chela : And, how did it go?
I just read an interesting article of a guy using cloudflare (https://itnext.io/using-cloudflare-tunnels-to-securely-expose-kubernetes-services-26713fb5da0a) to expose privately hosted services. This goes one step further than using noip.com. I did not try it, but cloudflare has a $0 plan for non-business use, so it could be really worth a try.
Thank you for following up.
I had to travel for my work just after I received your previous message and I am currently away from home.
I expect to return in the next week or so and thus be able to continue with my project, I hope to provide an update shortly after.