YunoHost 12.1.34 (stable)
mosquitto version 2.0.22
It took me some time to get this figured out so hopefully this may help others.
- Add a new domain
I used mqtt.local for this. I assume that one would need to adapt the default.conf file below for other domains / scenarios according to your requirements regarding websockets, TLS etc. but the comments in the original file are really helpful here (once you’ve found the file
)
Install Mosquitto from the apps catalogue
When all’s up and running I ran these commands (as root or sudo su):
cp /etc/mosquito/conf.d default.conf /etc/mosquito/conf.d default.conf
(only for cowards like me who like to keep a copy of the original
)
Edit the default.con file (I use nano here):
nano /etc/mosquito/conf.d/default.conf
My modified file looks then like this (btw.: I didn’t (yet) need to do the sudo yunohost firewall allow... command as port 1883 was already opened during installation):
log_timestamp_format %Y-%m-%dT%H:%M:%S
################### Direct IP
#To use mosquitto with direct IP call and no websocket protocol, uncomment those lines and comment
# those for websocket protocol
#You will need to open the firewall port with command "sudo yunohost firewall allow TCP 1883 --no-upnp"
listener 1883
###################SSL CONNECTION###########################################
#To use mosquitto with direct IP and SSL connection, uncomment those lines
#You will need to open the firewall port with command "sudo yunohost firewall allow TCP 8883 --no-upnp"
#listener 8883
#certfile /etc/yunohost/certs/mqtt.local/crt.pem
#cafile /etc/yunohost/certs/mqtt.local/crt.pem
#keyfile /etc/yunohost/certs/mqtt.local/key.pem
##############################################################################
#############################WEBSOCKET AND URL################################
#To use mosquitto with websocket protocol and a direct URL call, uncomment those lines and comment
#those for direct IP
#listener 1883 127.0.0.1
#listener 1883 ::1
#listener 8884
#protocol websockets
#certfile /etc/yunohost/certs/mqtt.local/crt.pem
#cafile /etc/yunohost/certs/mqtt.local/crt.pem
#keyfile /etc/yunohost/certs/mqtt.local/key.pem
#############################################################################
allow_anonymous false
password_file /etc/mosquitto/passwd
If you want to allow anonymous calls then modify the ”allow_anonymous false”
Line accordingly but I wouldn’t recommend this.
I was then finally able to go online:
Hope that this helps save other users’ time.
Fil


