Setup Secure MQTT Broker
ติดตั้ง certbot
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot
เปิด firewall allow port 80 และ certbot จะใช้ port 80
sudo ufw allow 80
ทำการสร้าง certificate
sudo certbot certonly — standalone — preferred-challenges http -d mqtt.example.com
แก้ไข config mosquitto
sudo nano /etc/mosquitto/mosquitto.conf
listener 8083
protocol websockets
certfile /etc/letsencrypt/live/mqtt.example.com/cert.pem
cafile /etc/letsencrypt/live/mqtt.example.com/chain.pem
keyfile /etc/letsencrypt/live/mqtt.example.com/privkey.pem
ทำการแก้ไข config letsencrypt เมื่อ renew certificate ให้ restart mosquitto
sudo nano /etc/letsencrypt/renewal/mqtt.example.com.conf
เพิ่มลงบรรทัดสุดท้าย
renew_hook = systemctl restart mosquitto
ทดสอบรันคำสั่ง renew
sudo certbot renew — dry-run
Developer Project : IoT Phuket Lab
https://iotphuketlab.home.blog/
https://medium.com/@aegkaluk
https://www.facebook.com/iotphuket/
https://www.youtube.com/user/MrAegkaluk
https://sites.google.com/view/iot-phuket-lab-documents
https://pantip.com/profile/368674#topics
แวะเยี่ยมชมสินค้าของทางร้าน
https://www.phuket-it.com/iotphuketlab/
https://www.lazada.co.th/shop/phuket-bike-lover
https://shopee.co.th/aegkaluk